mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Add upgrade script
This commit is contained in:
parent
9f19c2c7af
commit
ee0b1de8c1
1 changed files with 46 additions and 0 deletions
46
scripts/upgrade
Normal file
46
scripts/upgrade
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
APP=hotspot
|
||||||
|
OWNER=labriqueinternet
|
||||||
|
SERVICE="ynh-${APP}"
|
||||||
|
REPO="${APP}_ynh"
|
||||||
|
|
||||||
|
ARGS='domain path wifi_ssid wifi_passphrase'
|
||||||
|
|
||||||
|
if dpkg -l firmware-linux-nonfree &> /dev/null; then
|
||||||
|
args_url='firmware_nonfree=yes'
|
||||||
|
else
|
||||||
|
args_url='firmware_nonfree=no'
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_time=$(sudo yunohost app setting "${APP}" install_time)
|
||||||
|
install_isotime=$(date -Iseconds --date="@${install_time}")
|
||||||
|
|
||||||
|
commits=$(sudo curl -s "https://api.github.com/repos/${OWNER}/${REPO}/commits?since=${install_isotime}" | wc -l)
|
||||||
|
|
||||||
|
if [ "${commits}" -le 3 ]; then
|
||||||
|
echo "${APP}: Up-to-date"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in ${ARGS}; do
|
||||||
|
value=$(sudo yunohost app setting "${APP}" "${i}")
|
||||||
|
value=$(php -r "echo rawurlencode('$value');")
|
||||||
|
|
||||||
|
args_url="${args_url}&${i}=${value}"
|
||||||
|
done
|
||||||
|
|
||||||
|
tmpdir=$(mktemp -dp /tmp/ "${APP}-upgrade-XXXXX")
|
||||||
|
|
||||||
|
sudo systemctl stop "${SERVICE}"
|
||||||
|
sudo cp -a "/etc/yunohost/apps/${APP}/settings.yml" "${tmpdir}/"
|
||||||
|
|
||||||
|
sudo yunohost app remove "${APP}"
|
||||||
|
sudo yunohost app install "https://github.com/${OWNER}/${REPO}" --args "${args_url}"
|
||||||
|
|
||||||
|
sudo cp -a "${tmpdir}/settings.yml" "/etc/yunohost/apps/${APP}/"
|
||||||
|
sudo systemctl restart "${SERVICE}"
|
||||||
|
|
||||||
|
rm -r "${tmpdir}/"
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in a new issue