diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..5761e69 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,5 @@ +#!/bin/bash + +# nothing to do... + +exit 0 diff --git a/scripts/install b/scripts/install index ea2834d..935e10a 100644 --- a/scripts/install +++ b/scripts/install @@ -18,7 +18,7 @@ # along with this program. If not, see . # This is an upgrade? -upgrade=$([ "$HOTSPOT_UPGRADE" == 1 ] && echo true || echo false) +upgrade=$([ "${HOTSPOT_UPGRADE}" == 1 ] && echo true || echo false) # Retrieve arguments domain=${1} @@ -119,7 +119,7 @@ if ! $upgrade; then echo "ERROR: No wifi interface found" >&2 exit 1 fi - + # Save arguments sudo yunohost app setting hotspot service_enabled -v 1 sudo yunohost app setting hotspot multissid -v 1 @@ -140,6 +140,10 @@ if ! $upgrade; then fi +# Save git commit +gitcommit=$(git rev-parse HEAD) +sudo yunohost app setting hotspot gitcommit -v "${gitcommit}" + # Install custom scripts sudo install -o root -g root -m 0755 ../conf/iw_multissid /usr/local/bin/ sudo install -o root -g root -m 0755 ../conf/iw_devices /usr/local/bin/ diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..e962243 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,14 @@ +#!/bin/bash + +gitcommit=$(sudo yunohost app setting hotspot gitcommit) +tmpdir=$(mktemp -dp /tmp/ hotspot-restore-XXXXX) + +git clone https://github.com/labriqueinternet/hotspot_ynh.git "${tmpdir}/" +git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcommit}" + +cd "${tmpdir}/scripts/" +./upgrade + +sudo rm -r "${tmpdir}/" + +exit 0 diff --git a/scripts/upgrade b/scripts/upgrade index 1fd4391..f8162ee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,7 @@ else fi export HOTSPOT_UPGRADE=1 -sudo bash /etc/yunohost/apps/hotspot/scripts/remove +sudo bash /etc/yunohost/apps/hotspot/scripts/remove &> /dev/null bash ./install "${domain}" "${path}" "${wifi_ssid}" "${wifi_passphrase}" "${firmware_nonfree}" # Changes