diff options
author | grufo | 2020-09-14 03:21:25 +0100 |
---|---|---|
committer | grufo | 2020-09-14 03:21:25 +0100 |
commit | 580bfcea7e426e8f79425e42c50ff431bf0687a7 (patch) | |
tree | a10cb3069713d6631d5c3af68eccc2bf1b5e56d7 /xampp.install | |
parent | 55330402034810322d5db633d09ea157fe463e5f (diff) | |
download | aur-580bfcea7e426e8f79425e42c50ff431bf0687a7.tar.gz |
xampp.install: revised backup during package upgrade
Diffstat (limited to 'xampp.install')
-rw-r--r-- | xampp.install | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/xampp.install b/xampp.install index 229fbaed4d3e..b91659eb64eb 100644 --- a/xampp.install +++ b/xampp.install @@ -1,4 +1,4 @@ -# Like `backup` in `PKGBUILD`, but supports folders – no leading and trailing slashes here! +# Like `backup` in `PKGBUILD`, but supports folders – no leading and trailing slash here! _BACKUP=('opt/lampp/etc' 'opt/lampp/htdocs' 'opt/lampp/var') post_install() { @@ -31,13 +31,14 @@ post_install() { pre_upgrade() { - echo -n 'Stopping lampp services...' local _STDERR + local _COIN + + echo -n 'Stopping lampp services...' _STDERR="$(/opt/lampp/lampp stop >/dev/null 2>&1)" && echo ' OK' || (echo ' FAILED'; test "x${_STDERR}" != 'x' && echo "${_STDERR}") - local _COIN for _COIN in "${_BACKUP[@]}"; do - ! test -d "/${_COIN}" || mv "/${_COIN}" "/${_COIN}-backup" + ! test -d "/${_COIN}" || (rm -rf "/${_COIN}-backup" && mv "/${_COIN}" "/${_COIN}-backup") done } @@ -45,6 +46,7 @@ pre_upgrade() { post_upgrade() { local _COIN + for _COIN in "${_BACKUP[@]}"; do if test -d "/${_COIN}-backup"; then rm -rf "/${_COIN}.pacnew" @@ -57,18 +59,19 @@ post_upgrade() { pre_remove() { + local _STDERR + local _COIN local _DATESTAMP="$(date '+%Y-%m-%d-%H.%M.%S')" - echo -n 'Stopping lampp services...' - local _STDERR + echo -n 'Stopping lampp services...' _STDERR="$(/opt/lampp/lampp stop >/dev/null 2>&1)" && echo ' OK' || (echo ' FAILED'; test "x${_STDERR}" != 'x' && echo "${_STDERR}") - local _COIN for _COIN in "${_BACKUP[@]}"; do rm -rf "/${_COIN}.pacnew" done install -dm755 '/opt/htdocs-backups' + rm -rf "/opt/htdocs-backups/${_DATESTAMP}" mv '/opt/lampp/htdocs' "/opt/htdocs-backups/${_DATESTAMP}" || echo 'ERROR: Could not create a backup of /opt/lampp/htdocs.' 1>&2 rm -rf '/opt/lampp/var' '/opt/lampp/temp' '/opt/lampp/etc' '/opt/lampp/phpmyadmin/tmp' @@ -82,3 +85,4 @@ post_remove() { echo } + |