1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hotspot_ynh.git synced 2024-09-03 19:25:53 +02:00
hotspot_ynh/scripts/upgrade

53 lines
1.3 KiB
Text
Raw Normal View History

2015-07-13 15:59:05 +02:00
#!/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}"
2015-07-13 17:23:33 +02:00
install_time=$(sudo yunohost app setting "${APP}" install_time)
2015-07-13 15:59:05 +02:00
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}"
2015-07-13 17:23:33 +02:00
sudo systemctl stop "${SERVICE}"
2015-07-13 15:59:05 +02:00
sudo cp -a "${tmpdir}/settings.yml" "/etc/yunohost/apps/${APP}/"
2015-07-13 17:23:33 +02:00
sudo yunohost app setting "${APP}" install_time -v "${install_time}"
sudo systemctl start "${SERVICE}"
2015-07-13 15:59:05 +02:00
2015-07-13 16:01:38 +02:00
sudo rm -r "${tmpdir}/"
2015-07-13 15:59:05 +02:00
exit 0