Improve phpmyadmin upgrade

* query phpmyadmin.net api to get the latest version
This commit is contained in:
VirtuBox
2020-04-22 17:50:01 +02:00
parent b1e9262f92
commit 913d5edf22
5 changed files with 33 additions and 15 deletions

1
.gitattributes vendored
View File

@@ -17,6 +17,7 @@
*.bash text eol=lf *.bash text eol=lf
*.fish text eol=lf *.fish text eol=lf
*.sh text eol=lf *.sh text eol=lf
*.rc text eol=lf
# Source files # Source files
# ============ # ============

View File

@@ -154,7 +154,7 @@ _wo_complete()
"create") "create")
COMPREPLY=( $(compgen \ 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) ) -- $cur) )
;; ;;
@@ -206,7 +206,7 @@ _wo_complete()
"--wp") "--wp")
if [ "${COMP_WORDS[1]}" != "debug" ]; then if [ "${COMP_WORDS[1]}" != "debug" ]; then
if [ "${COMP_WORDS[2]}" == "create" ]; 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 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" retlist="--wp --wpfc --wpsc --php72 --php73 --php74 --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon"
else else
@@ -225,7 +225,7 @@ _wo_complete()
"--wpsubdir" | "--wpsubdomain") "--wpsubdir" | "--wpsubdomain")
if [ "${COMP_WORDS[1]}" != "debug" ]; then if [ "${COMP_WORDS[1]}" != "debug" ]; then
if [ "${COMP_WORDS[2]}" == "create" ]; 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 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" retlist="--wpfc --wpsc --php72 --php73 --php74 --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon"
else else
@@ -243,7 +243,7 @@ _wo_complete()
"--wpredis" | "--wprocket" | "--wpce" | "--wpfc" | "--wpsc" | "--wpsubdir" | "--wpsubdomain" | "--user" | "--pass" | "--email" | "--wp") "--wpredis" | "--wprocket" | "--wpce" | "--wpfc" | "--wpsc" | "--wpsubdir" | "--wpsubdomain" | "--user" | "--pass" | "--email" | "--wp")
if [ "${COMP_WORDS[2]}" == "create" ]; then 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 else
retlist="" retlist=""
fi fi
@@ -267,7 +267,7 @@ _wo_complete()
-- $cur) ) -- $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 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" 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 elif [[ "${COMP_WORDS[2]}" == "start" || "${COMP_WORDS[2]}" == "reload" || "${COMP_WORDS[2]}" == "restart" || "${COMP_WORDS[2]}" == "stop" ]]; then

View File

@@ -133,15 +133,16 @@ class WOSecureController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def secure_ip(self): def secure_ip(self):
"""IP whitelisting""" """IP whitelisting"""
WOGit.add(self, ["/etc/nginx"], if os.path.exists('/etc/nginx'):
msg="Add Nginx to into Git") WOGit.add(self, ["/etc/nginx"],
msg="Add Nginx to into Git")
pargs = self.app.pargs pargs = self.app.pargs
if not pargs.user_input: if not pargs.user_input:
ip = input("Enter the comma separated IP addresses " ip = input("Enter the comma separated IP addresses "
"to white list [127.0.0.1]:") "to white list [127.0.0.1]:")
pargs.user_input = ip pargs.user_input = ip
try: try:
user_ip = pargs.user_input.split(',') user_ip = pargs.user_input.strip().split(',')
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
user_ip = ['127.0.0.1'] user_ip = ['127.0.0.1']
@@ -170,8 +171,9 @@ class WOSecureController(CementBaseController):
'Harden SSH security [y/N]') 'Harden SSH security [y/N]')
if start_secure != "Y" and start_secure != "y": if start_secure != "Y" and start_secure != "y":
Log.error(self, "Not hardening SSH security") Log.error(self, "Not hardening SSH security")
WOGit.add(self, ["/etc/ssh"], if os.path.exists('/etc/ssh'):
msg="Adding SSH into Git") WOGit.add(self, ["/etc/ssh"],
msg="Adding SSH into Git")
Log.debug(self, "check if /etc/ssh/sshd_config exist") Log.debug(self, "check if /etc/ssh/sshd_config exist")
if os.path.isfile('/etc/ssh/sshd_config'): if os.path.isfile('/etc/ssh/sshd_config'):
Log.debug(self, "looking for the current ssh port") Log.debug(self, "looking for the current ssh port")

View File

@@ -76,6 +76,7 @@ class WOStackUpgradeController(CementBaseController):
packages = [] packages = []
self.msg = [] self.msg = []
pargs = self.app.pargs pargs = self.app.pargs
wo_phpmyadmin = WODownload.pma_release(self)
if not (pargs.web or pargs.nginx or pargs.php or if not (pargs.web or pargs.nginx or pargs.php or
pargs.php72 or pargs.php73 or pargs.php74 or pargs.mysql or pargs.php72 or pargs.php73 or pargs.php74 or pargs.mysql or
pargs.ngxblocker or pargs.all or pargs.netdata or pargs.ngxblocker or pargs.all or pargs.netdata or
@@ -207,7 +208,7 @@ class WOStackUpgradeController(CementBaseController):
"https://files.phpmyadmin.net" "https://files.phpmyadmin.net"
"/phpMyAdmin/{0}/phpMyAdmin-{0}-" "/phpMyAdmin/{0}/phpMyAdmin-{0}-"
"all-languages.tar.gz" "all-languages.tar.gz"
.format(WOVar.wo_phpmyadmin), .format(wo_phpmyadmin),
"/var/lib/wo/tmp/pma.tar.gz", "/var/lib/wo/tmp/pma.tar.gz",
"PHPMyAdmin"]] "PHPMyAdmin"]]
else: else:
@@ -403,13 +404,13 @@ class WOStackUpgradeController(CementBaseController):
.format(WOVar.wo_webroot)), .format(WOVar.wo_webroot)),
('/var/lib/wo/tmp/phpMyAdmin-{0}' ('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/config.inc.php' '-all-languages/config.inc.php'
.format(WOVar.wo_phpmyadmin)) .format(wo_phpmyadmin))
) )
WOFileUtils.rm(self, '{0}22222/htdocs/db/pma' WOFileUtils.rm(self, '{0}22222/htdocs/db/pma'
.format(WOVar.wo_webroot)) .format(WOVar.wo_webroot))
shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}' shutil.move('/var/lib/wo/tmp/phpMyAdmin-{0}'
'-all-languages/' '-all-languages/'
.format(WOVar.wo_phpmyadmin), .format(wo_phpmyadmin),
'{0}22222/htdocs/db/pma/' '{0}22222/htdocs/db/pma/'
.format(WOVar.wo_webroot)) .format(WOVar.wo_webroot))
WOFileUtils.chown(self, "{0}22222/htdocs" WOFileUtils.chown(self, "{0}22222/htdocs"

View File

@@ -36,7 +36,7 @@ class WODownload():
return False return False
return 0 return 0
def latest_release(self, repository): def latest_release(self, repository, name=False):
"""Get the latest release number of a GitHub repository.\n """Get the latest release number of a GitHub repository.\n
repository format should be: \"user/repo\"""" repository format should be: \"user/repo\""""
try: try:
@@ -48,5 +48,19 @@ class WODownload():
except requests.RequestException as e: except requests.RequestException as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "Unable to query GitHub API") 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"]