mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Update upgrade
This commit is contained in:
parent
81993b700a
commit
979e467ef0
2 changed files with 100 additions and 135 deletions
|
@ -17,6 +17,9 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# This is an upgrade?
|
||||||
|
upgrade=$([ "$HOTSPOT_UPGRADE" == 1 ] && echo true || echo false)
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=${1}
|
domain=${1}
|
||||||
url_path=${2}
|
url_path=${2}
|
||||||
|
@ -24,12 +27,7 @@ wifi_ssid=${3}
|
||||||
wifi_passphrase=${4}
|
wifi_passphrase=${4}
|
||||||
firmware_nonfree=${5}
|
firmware_nonfree=${5}
|
||||||
|
|
||||||
##
|
if ! $upgrade; then
|
||||||
## These arguments are optional but YunoHost is not yet able to handle them with the web installer
|
|
||||||
## See manifest.json.options
|
|
||||||
##
|
|
||||||
#
|
|
||||||
#ip6_net=${6}
|
|
||||||
|
|
||||||
# Check YunoHost version
|
# Check YunoHost version
|
||||||
ynh_version=$(sudo dpkg -l yunohost | grep ii | awk '{ print $3 }' | sed 's/\.//g')
|
ynh_version=$(sudo dpkg -l yunohost | grep ii | awk '{ print $3 }' | sed 's/\.//g')
|
||||||
|
@ -70,6 +68,8 @@ if [ ! $? -eq 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
packages='php5-fpm sipcalc hostapd iptables iw dnsmasq'
|
packages='php5-fpm sipcalc hostapd iptables iw dnsmasq'
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
@ -95,6 +95,8 @@ if [ $? -ne 0 ]; then
|
||||||
sudo apt-get --assume-yes --force-yes install ${packages}
|
sudo apt-get --assume-yes --force-yes install ${packages}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! $upgrade; then
|
||||||
|
|
||||||
# Compute extra arguments
|
# Compute extra arguments
|
||||||
if [ -z "${ip6_net}" ]; then
|
if [ -z "${ip6_net}" ]; then
|
||||||
ip6_net=none
|
ip6_net=none
|
||||||
|
@ -109,17 +111,6 @@ if [ -z "${ip6_net}" ]; then
|
||||||
ip6_addr=${vpnclient_ip6_addr}
|
ip6_addr=${vpnclient_ip6_addr}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#else
|
|
||||||
# ip6_net=$(bash ../conf/ipv6_expanded "${ip6_net}")
|
|
||||||
#
|
|
||||||
# if [ -z "${ip6_net}" ]; then
|
|
||||||
# echo "ERROR: The IPv6 Delegated Prefix format looks bad" >&2
|
|
||||||
# exit 1
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# ip6_addr="$(echo "${ip6_net}" | cut -d: -f1-7):42"
|
|
||||||
# ip6_net=$(bash ../conf/ipv6_compressed "${ip6_net}")
|
|
||||||
# ip6_addr=$(bash ../conf/ipv6_compressed "${ip6_addr}")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wifi_device=$(sudo bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
wifi_device=$(sudo bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
||||||
|
@ -146,6 +137,8 @@ sudo yunohost app setting hotspot ip4_dns1 -v 80.67.169.12
|
||||||
sudo yunohost app setting hotspot ip4_nat_prefix -v 10.0.242
|
sudo yunohost app setting hotspot ip4_nat_prefix -v 10.0.242
|
||||||
sudo yunohost app setting hotspot vpnclient -v no
|
sudo yunohost app setting hotspot vpnclient -v no
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Install custom scripts
|
# 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_multissid /usr/local/bin/
|
||||||
sudo install -o root -g root -m 0755 ../conf/iw_devices /usr/local/bin/
|
sudo install -o root -g root -m 0755 ../conf/iw_devices /usr/local/bin/
|
||||||
|
@ -203,10 +196,8 @@ sudo yunohost firewall allow --no-upnp UDP 67
|
||||||
# and the ynh-hotspot service handles them.
|
# and the ynh-hotspot service handles them.
|
||||||
sudo systemctl disable hostapd
|
sudo systemctl disable hostapd
|
||||||
sudo systemctl stop hostapd
|
sudo systemctl stop hostapd
|
||||||
|
|
||||||
sudo systemctl enable php5-fpm
|
sudo systemctl enable php5-fpm
|
||||||
sudo systemctl restart php5-fpm
|
sudo systemctl restart php5-fpm
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
sudo systemctl reload nginx
|
||||||
|
|
||||||
# Remove IPv6 address set if there is a VPN installed
|
# Remove IPv6 address set if there is a VPN installed
|
||||||
|
@ -217,10 +208,12 @@ if [ "${ip6_addr}" != none ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! $upgrade; then
|
||||||
sudo systemctl enable ynh-hotspot
|
sudo systemctl enable ynh-hotspot
|
||||||
sudo systemctl start ynh-hotspot
|
sudo systemctl start ynh-hotspot
|
||||||
|
|
||||||
# Update SSO for wifiadmin
|
sudo yunohost service add ynh-hotspot
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1,52 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
APP=hotspot
|
yunohost_setting() {
|
||||||
OWNER=labriqueinternet
|
grep "^${1}:" "/etc/yunohost/apps/hotspot/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$//
|
||||||
SERVICE="ynh-${APP}"
|
}
|
||||||
REPO="${APP}_ynh"
|
|
||||||
|
|
||||||
ARGS='domain path wifi_ssid wifi_passphrase'
|
domain=$(yunohost_setting domain)
|
||||||
|
path=$(yunohost_setting path)
|
||||||
|
wifi_ssid=$(yunohost_setting wifi_ssid)
|
||||||
|
wifi_passphrase=$(yunohost_setting wifi_passphrase)
|
||||||
|
|
||||||
if dpkg -l firmware-linux-nonfree &> /dev/null; then
|
if dpkg -l firmware-linux-nonfree &> /dev/null; then
|
||||||
args_url='firmware_nonfree=yes'
|
firmware_nonfree=yes
|
||||||
else
|
else
|
||||||
args_url='firmware_nonfree=no'
|
firmware_nonfree=no
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install_time=$(sudo yunohost app setting "${APP}" install_time)
|
export HOTSPOT_UPGRADE=1
|
||||||
install_isotime=$(date -Iseconds --date="@${install_time}")
|
/etc/yunohost/apps/hotspot/scripts/remove
|
||||||
|
./install "${domain}" "${path}" "${wifi_ssid}" "${wifi_passphrase}" "${firmware_nonfree}"
|
||||||
|
|
||||||
commits=$(sudo curl -s "https://api.github.com/repos/${OWNER}/${REPO}/commits?since=${install_isotime}" | wc -l)
|
sudo systemctl start ynh-hotspot
|
||||||
|
|
||||||
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 systemctl stop "${SERVICE}"
|
|
||||||
|
|
||||||
install_time=$(sudo yunohost app setting "${APP}" install_time)
|
|
||||||
sudo cp -a "${tmpdir}/settings.yml" "/etc/yunohost/apps/${APP}/"
|
|
||||||
sudo yunohost app setting "${APP}" install_time -v "${install_time}"
|
|
||||||
|
|
||||||
sudo systemctl start "${SERVICE}"
|
|
||||||
|
|
||||||
sudo rm -r "${tmpdir}/"
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue