Several fixes
This commit is contained in:
@@ -8,6 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
|
||||
### v3.9.x - [Unreleased]
|
||||
|
||||
#### Fixed
|
||||
|
||||
- ufw rules for proftpd not applied
|
||||
- phpredisadmin install
|
||||
- netdata configuration
|
||||
|
||||
|
||||
### v3.9.8.7 - 2019-08-31
|
||||
|
||||
#### Changed
|
||||
|
||||
@@ -312,6 +312,9 @@ class WOStackController(CementBaseController):
|
||||
|
||||
# Composer
|
||||
if pargs.composer:
|
||||
if ((not WOAptGet.is_installed(self, 'php7.2-fpm')) and
|
||||
(not WOAptGet.is_installed(self, 'php7.3-fpm'))):
|
||||
pargs.php = True
|
||||
if not os.path.isfile('/usr/local/bin/composer'):
|
||||
Log.debug(self, "Setting packages variable for Composer ")
|
||||
packages = packages + [["https://getcomposer.org/"
|
||||
|
||||
@@ -47,11 +47,13 @@ def pre_pref(self, apt_packages):
|
||||
if set(WOVariables.wo_mysql).issubset(set(apt_packages)):
|
||||
# generate random 24 characters root password
|
||||
chars = ''.join(random.sample(string.ascii_letters, 24))
|
||||
|
||||
# configure MySQL non-interactive install
|
||||
if (not WOVariables.wo_distro == 'raspbian'):
|
||||
mariadb_ver = '10.3'
|
||||
else:
|
||||
if ((WOVariables.wo_distro == 'raspbian') and
|
||||
(WOVariables.wo_platform_codename == 'stretch')):
|
||||
mariadb_ver = '10.1'
|
||||
else:
|
||||
mariadb_ver = '10.3'
|
||||
|
||||
Log.debug(self, "Pre-seeding MySQL")
|
||||
Log.debug(self, "echo \"mariadb-server-{0} "
|
||||
@@ -1072,16 +1074,19 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
WOService.restart_service(self, 'proftpd')
|
||||
|
||||
# add rule for proftpd with UFW
|
||||
if WOAptGet.is_installed(self, 'ufw'):
|
||||
if os.path.isdir('/etc/ufw'):
|
||||
try:
|
||||
WOShellExec.cmd_exec(self, "/usr/bin/ufw allow "
|
||||
"49000:50000/tcp")
|
||||
WOShellExec.cmd_exec(
|
||||
self, "ufw allow 49000:50000/tcp")
|
||||
WOShellExec.cmd_exec(
|
||||
self, "ufw reload")
|
||||
except CommandExecutionError as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error(self, "Unable to add UFW rule")
|
||||
|
||||
if ((os.path.isfile("/etc/fail2ban/jail.d/custom.conf")) and
|
||||
(not WOFileUtils.grep(self, "/etc/fail2ban/jail.d/custom.conf",
|
||||
(not WOFileUtils.grep(
|
||||
self, "/etc/fail2ban/jail.d/custom.conf",
|
||||
"proftpd"))):
|
||||
with open("/etc/fail2ban/jail.d/custom.conf",
|
||||
encoding='utf-8', mode='a') as f2bproftpd:
|
||||
@@ -1108,16 +1113,12 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
if not os.path.isfile("/etc/nginx/conf.d/redis.conf"):
|
||||
with open("/etc/nginx/conf.d/redis.conf",
|
||||
"a") as redis_file:
|
||||
redis_file.write("# Log format Settings\n"
|
||||
"log_format rt_cache_redis "
|
||||
"'$remote_addr "
|
||||
"$upstream_response_time "
|
||||
"$srcache_fetch_status "
|
||||
"[$time_local]"
|
||||
" '\n '$http_host"
|
||||
" \"$request\" "
|
||||
"$status $body_bytes_sent '\n"
|
||||
"'\"$http_referer\" "
|
||||
redis_file.write(
|
||||
"# Log format Settings\n"
|
||||
"log_format rt_cache_redis '$remote_addr "
|
||||
"$upstream_response_time $srcache_fetch_status "
|
||||
"[$time_local] '\n '$http_host \"$request\" "
|
||||
"$status $body_bytes_sent '\n'\"$http_referer\" "
|
||||
"\"$http_user_agent\"';\n")
|
||||
# set redis.conf parameter
|
||||
# set maxmemory 10% for ram below 512MB and 20% for others
|
||||
@@ -1158,12 +1159,10 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
Log.debug(
|
||||
self, "Setting maxmemory-policy variable to "
|
||||
"allkeys-lru in redis.conf")
|
||||
WOFileUtils.searchreplace(self,
|
||||
"/etc/redis/redis.conf",
|
||||
"# maxmemory-policy "
|
||||
"noeviction",
|
||||
"maxmemory-policy "
|
||||
"allkeys-lru")
|
||||
WOFileUtils.searchreplace(
|
||||
self, "/etc/redis/redis.conf",
|
||||
"# maxmemory-policy noeviction",
|
||||
"maxmemory-policy allkeys-lru")
|
||||
Log.debug(
|
||||
self, "Setting tcp-backlog variable to "
|
||||
"in redis.conf")
|
||||
@@ -1268,7 +1267,9 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
shutil.copyfile('/var/lib/wo/tmp/composer.phar',
|
||||
'/usr/local/bin/composer')
|
||||
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
|
||||
if os.path.isdir("/var/www/22222/htdocs/db/pma"):
|
||||
if ((os.path.isdir("/var/www/22222/htdocs/db/pma")) and
|
||||
(not os.path.isfile('/var/www/22222/htdocs/db/'
|
||||
'pma/composer.lock'))):
|
||||
Log.info(self, "Updating phpMyAdmin, please wait...")
|
||||
WOShellExec.cmd_exec(
|
||||
self, "/usr/local/bin/composer update "
|
||||
@@ -1289,6 +1290,14 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
.format(WOVariables.wo_webroot))
|
||||
os.makedirs('{0}22222/htdocs/cache/redis/phpRedisAdmin'
|
||||
.format(WOVariables.wo_webroot))
|
||||
if not os.path.isfile('/var/www/22222/htdocs/cache/redis/'
|
||||
'phpRedisAdmin/composer.lock'):
|
||||
WOShellExec.cmd_exec(self, "/usr/local/bin/composer"
|
||||
"create-project --no-plugins "
|
||||
"--no-scripts -n -s dev "
|
||||
"erik-dubbelboer/php-redis-admin "
|
||||
"/var/www/22222/htdocs/cache"
|
||||
"/redis/phpRedisAdmin ")
|
||||
WOFileUtils.chown(self, '{0}22222/htdocs'
|
||||
.format(WOVariables.wo_webroot),
|
||||
'www-data',
|
||||
@@ -1304,32 +1313,29 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
# netdata install
|
||||
if any('/var/lib/wo/tmp/kickstart.sh' == x[1]
|
||||
for x in packages):
|
||||
if ((not os.path.exists('/opt/netdata')) and
|
||||
(not os.path.exists('/etc/netdata'))):
|
||||
Log.info(self, "Installing Netdata, please wait...")
|
||||
WOShellExec.cmd_exec(self, "bash /var/lib/wo/tmp/"
|
||||
"kickstart.sh "
|
||||
"--dont-wait")
|
||||
if WOVariables.wo_distro == 'raspbian':
|
||||
if os.path.isdir('/etc/netdata'):
|
||||
wo_netdata = "/"
|
||||
else:
|
||||
elif os.path.isdir('/opt/netdata'):
|
||||
wo_netdata = "/opt/netdata/"
|
||||
# disable mail notifications
|
||||
WOFileUtils.searchreplace(
|
||||
self, "{0}usr/"
|
||||
"lib/netdata/conf.d/health_alarm_notify.conf"
|
||||
self, "{0}etc/netdata/orig/health_alarm_notify.conf"
|
||||
.format(wo_netdata),
|
||||
'SEND_EMAIL="YES"',
|
||||
'SEND_EMAIL="NO"')
|
||||
# make changes persistant
|
||||
WOFileUtils.copyfile(
|
||||
self, "{0}usr/lib/netdata/conf.d/"
|
||||
self, "{0}etc/netdata/orig/"
|
||||
"health_alarm_notify.conf"
|
||||
.format(wo_netdata),
|
||||
"{0}etc/netdata/health_alarm_notify.conf"
|
||||
.format(wo_netdata))
|
||||
# check if mysql credentials are available
|
||||
if os.path.isfile('/etc/mysql/conf.d/my.cnf'):
|
||||
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
|
||||
try:
|
||||
WOMysql.execute(
|
||||
self,
|
||||
|
||||
@@ -80,7 +80,7 @@ class WOFileUtils():
|
||||
except IOError as e:
|
||||
Log.debug(self, "{0}".format(e.strerror))
|
||||
Log.error(self, "Unable to copy files from {0} to {1}"
|
||||
.format(src, dest))
|
||||
.format(src, dest), exit=False)
|
||||
|
||||
def copyfile(self, src, dest):
|
||||
"""
|
||||
@@ -99,7 +99,7 @@ class WOFileUtils():
|
||||
except IOError as e:
|
||||
Log.debug(self, "{0}".format(e.strerror))
|
||||
Log.error(self, "Unable to copy file from {0} to {1}"
|
||||
.format(src, dest))
|
||||
.format(src, dest), exit=False)
|
||||
|
||||
def searchreplace(self, fnm, sstr, rstr):
|
||||
"""
|
||||
@@ -118,7 +118,7 @@ class WOFileUtils():
|
||||
except Exception as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
Log.error(self, "Unable to search {0} and replace {1} {2}"
|
||||
.format(fnm, sstr, rstr))
|
||||
.format(fnm, sstr, rstr), exit=False)
|
||||
|
||||
def mvfile(self, src, dst):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user