Improve phpmyadmin upgrade
* query phpmyadmin.net api to get the latest version
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -17,6 +17,7 @@
|
||||
*.bash text eol=lf
|
||||
*.fish text eol=lf
|
||||
*.sh text eol=lf
|
||||
*.rc text eol=lf
|
||||
|
||||
# Source files
|
||||
# ============
|
||||
|
||||
@@ -154,7 +154,7 @@ _wo_complete()
|
||||
|
||||
"create")
|
||||
COMPREPLY=( $(compgen \
|
||||
-W "--user --pass --email --html --php --php73 --php74 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --proxy= --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" \
|
||||
-W "--user --pass --email --html --php --php72 --php73 --php74 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --proxy= --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" \
|
||||
-- $cur) )
|
||||
;;
|
||||
|
||||
@@ -206,7 +206,7 @@ _wo_complete()
|
||||
"--wp")
|
||||
if [ "${COMP_WORDS[1]}" != "debug" ]; then
|
||||
if [ "${COMP_WORDS[2]}" == "create" ]; then
|
||||
retlist="--wp --wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce --letsencrypt -le --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon --php73 --php74"
|
||||
retlist="--wp --wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce --letsencrypt -le --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon --php72 --php73 --php74"
|
||||
elif [ "${COMP_WORDS[2]}" == "update" ]; then
|
||||
retlist="--wp --wpfc --wpsc --php72 --php73 --php74 --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon"
|
||||
else
|
||||
@@ -225,7 +225,7 @@ _wo_complete()
|
||||
"--wpsubdir" | "--wpsubdomain")
|
||||
if [ "${COMP_WORDS[1]}" != "debug" ]; then
|
||||
if [ "${COMP_WORDS[2]}" == "create" ]; then
|
||||
retlist="--wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --php73 --php74 --dns --dns=dns_cf --dns=dns_dgon"
|
||||
retlist="--wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --php72 --php73 --php74 --dns --dns=dns_cf --dns=dns_dgon"
|
||||
elif [ "${COMP_WORDS[2]}" == "update" ]; then
|
||||
retlist="--wpfc --wpsc --php72 --php73 --php74 --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon"
|
||||
else
|
||||
@@ -243,7 +243,7 @@ _wo_complete()
|
||||
|
||||
"--wpredis" | "--wprocket" | "--wpce" | "--wpfc" | "--wpsc" | "--wpsubdir" | "--wpsubdomain" | "--user" | "--pass" | "--email" | "--wp")
|
||||
if [ "${COMP_WORDS[2]}" == "create" ]; then
|
||||
retlist="--user --pass --email --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce --php73 --php74 -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon"
|
||||
retlist="--user --pass --email --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce --php72 --php73 --php74 -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon"
|
||||
else
|
||||
retlist=""
|
||||
fi
|
||||
@@ -267,7 +267,7 @@ _wo_complete()
|
||||
-- $cur) )
|
||||
;;
|
||||
|
||||
"--web" | "--admin" | "--nginx" | "--php" | "--php73" | "--php74" | "--mysql" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--fail2ban" | "--ufw" | "--redis" | "--phpredisadmin" | "--netdata" | "--sendmail" | "--composer" | "--proftpd" | "--cheat" | "--nanorc" | "--clamav")
|
||||
"--web" | "--admin" | "--nginx" | "--php" | "--php73" | "--php74" | "--mysql" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--fail2ban" | "--ufw" | "--redis" | "--phpredisadmin" | "--netdata" | "--sendmail" | "--composer" | "--proftpd" | "--cheat" | "--nanorc" | "--clamav" | "--dashboard")
|
||||
if [[ "${COMP_WORDS[2]}" == "install" || "${COMP_WORDS[2]}" == "purge" || "${COMP_WORDS[2]}" == "remove" ]]; then
|
||||
retlist="--web --admin --security --nginx --php --php73 --php74 --mysql --wpcli --phpmyadmin --adminer --utils --redis --fail2ban --ufw --phpredisadmin --netdata --force"
|
||||
elif [[ "${COMP_WORDS[2]}" == "start" || "${COMP_WORDS[2]}" == "reload" || "${COMP_WORDS[2]}" == "restart" || "${COMP_WORDS[2]}" == "stop" ]]; then
|
||||
|
||||
@@ -133,15 +133,16 @@ class WOSecureController(CementBaseController):
|
||||
@expose(hide=True)
|
||||
def secure_ip(self):
|
||||
"""IP whitelisting"""
|
||||
WOGit.add(self, ["/etc/nginx"],
|
||||
msg="Add Nginx to into Git")
|
||||
if os.path.exists('/etc/nginx'):
|
||||
WOGit.add(self, ["/etc/nginx"],
|
||||
msg="Add Nginx to into Git")
|
||||
pargs = self.app.pargs
|
||||
if not pargs.user_input:
|
||||
ip = input("Enter the comma separated IP addresses "
|
||||
"to white list [127.0.0.1]:")
|
||||
pargs.user_input = ip
|
||||
try:
|
||||
user_ip = pargs.user_input.split(',')
|
||||
user_ip = pargs.user_input.strip().split(',')
|
||||
except Exception as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
user_ip = ['127.0.0.1']
|
||||
@@ -170,8 +171,9 @@ class WOSecureController(CementBaseController):
|
||||
'Harden SSH security [y/N]')
|
||||
if start_secure != "Y" and start_secure != "y":
|
||||
Log.error(self, "Not hardening SSH security")
|
||||
WOGit.add(self, ["/etc/ssh"],
|
||||
msg="Adding SSH into Git")
|
||||
if os.path.exists('/etc/ssh'):
|
||||
WOGit.add(self, ["/etc/ssh"],
|
||||
msg="Adding SSH into Git")
|
||||
Log.debug(self, "check if /etc/ssh/sshd_config exist")
|
||||
if os.path.isfile('/etc/ssh/sshd_config'):
|
||||
Log.debug(self, "looking for the current ssh port")
|
||||
|
||||
@@ -76,6 +76,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
packages = []
|
||||
self.msg = []
|
||||
pargs = self.app.pargs
|
||||
wo_phpmyadmin = WODownload.pma_release(self)
|
||||
if not (pargs.web or pargs.nginx or pargs.php or
|
||||
pargs.php72 or pargs.php73 or pargs.php74 or pargs.mysql or
|
||||
pargs.ngxblocker or pargs.all or pargs.netdata or
|
||||
@@ -207,7 +208,7 @@ class WOStackUpgradeController(CementBaseController):
|
||||
"https://files.phpmyadmin.net"
|
||||
"/phpMyAdmin/{0}/phpMyAdmin-{0}-"
|
||||
"all-languages.tar.gz"
|
||||
.format(WOVar.wo_phpmyadmin),
|
||||
.format(wo_phpmyadmin),
|
||||
"/var/lib/wo/tmp/pma.tar.gz",
|
||||
"PHPMyAdmin"]]
|
||||
else:
|
||||
@@ -403,13 +404,13 @@ class WOStackUpgradeController(CementBaseController):
|
||||
.format(WOVar.wo_webroot)),
|
||||
('/var/lib/wo/tmp/phpMyAdmin-{0}'
|
||||
'-all-languages/config.inc.php'
|
||||
.format(WOVar.wo_phpmyadmin))
|
||||
.format(wo_phpmyadmin))
|
||||
)
|
||||
WOFileUtils.rm(self, '{0}22222/htdocs/db/pma'
|
||||
.format(WOVar.wo_webroot))
|
||||
shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}'
|
||||
'-all-languages/'
|
||||
.format(WOVar.wo_phpmyadmin),
|
||||
.format(wo_phpmyadmin),
|
||||
'{0}22222/htdocs/db/pma/'
|
||||
.format(WOVar.wo_webroot))
|
||||
WOFileUtils.chown(self, "{0}22222/htdocs"
|
||||
|
||||
@@ -36,7 +36,7 @@ class WODownload():
|
||||
return False
|
||||
return 0
|
||||
|
||||
def latest_release(self, repository):
|
||||
def latest_release(self, repository, name=False):
|
||||
"""Get the latest release number of a GitHub repository.\n
|
||||
repository format should be: \"user/repo\""""
|
||||
try:
|
||||
@@ -48,5 +48,19 @@ class WODownload():
|
||||
except requests.RequestException as e:
|
||||
Log.debug(self, str(e))
|
||||
Log.error(self, "Unable to query GitHub API")
|
||||
if name:
|
||||
return github_json["name"]
|
||||
else:
|
||||
return github_json["tag_name"]
|
||||
|
||||
return github_json["tag_name"]
|
||||
def pma_release(self):
|
||||
"""Get the latest phpmyadmin release number from a json file"""
|
||||
try:
|
||||
req = requests.get(
|
||||
'https://www.phpmyadmin.net/home_page/version.json',
|
||||
timeout=(5, 30))
|
||||
pma_json = req.json()
|
||||
except requests.RequestException as e:
|
||||
Log.debug(self, str(e))
|
||||
Log.error(self, "Unable to query phpmyadmin API")
|
||||
return pma_json["version"]
|
||||
|
||||
Reference in New Issue
Block a user