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

Merge pull request #37 from keomabrun/dev_36

Fix #36 package_linter checks
This commit is contained in:
Keoma Brun 2019-02-10 01:16:47 +01:00 committed by GitHub
commit 60b54c05c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 54 deletions

View file

@ -45,6 +45,7 @@
}, },
{ {
"name": "wifi_ssid", "name": "wifi_ssid",
"type": "string",
"ask": { "ask": {
"en": "Choose a wifi name (SSID)", "en": "Choose a wifi name (SSID)",
"fr": "Choisissez un nom pour le wifi (SSID)" "fr": "Choisissez un nom pour le wifi (SSID)"
@ -63,6 +64,7 @@
}, },
{ {
"name": "firmware_nonfree", "name": "firmware_nonfree",
"type": "string",
"choice": ["yes", "no"], "choice": ["yes", "no"],
"ask": { "ask": {
"en": "Install non-free firmwares - in addition to the free ones - for the wifi dongle (yes/no)", "en": "Install non-free firmwares - in addition to the free ones - for the wifi dongle (yes/no)",

View file

@ -24,12 +24,12 @@ function ynh_systemctl()
local LOCKFILE="/var/run/moulinette_yunohost.lock" local LOCKFILE="/var/run/moulinette_yunohost.lock"
# Launch the action # Launch the action
sudo systemctl "$ACTION" "$SERVICE" & systemctl "$ACTION" "$SERVICE" &
local SYSCTLACTION=$! local SYSCTLACTION=$!
# Save and release the lock... # Save and release the lock...
cp $LOCKFILE $LOCKFILE.bkp.$$ cp $LOCKFILE $LOCKFILE.bkp.$$
rm $LOCKFILE ynh_secure_remove $LOCKFILE
# Wait for the end of the action # Wait for the end of the action
wait $SYSCTLACTION wait $SYSCTLACTION

View file

@ -119,7 +119,7 @@ export DEBIAN_FRONTEND=noninteractive
if [[ $firmware_nonfree == yes ]]; then if [[ $firmware_nonfree == yes ]]; then
# check if non-free is set on sources.list # check if non-free is set on sources.list
if ! grep -q non-free /etc/apt/sources.list ; then if ! grep -q non-free /etc/apt/sources.list ; then
sudo sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list
fi fi
packages=$nonfree_packages packages=$nonfree_packages
@ -130,15 +130,15 @@ else
# https://www.fsf.org/news/ryf-certification-thinkpenguin-usb-with-atheros-chip # https://www.fsf.org/news/ryf-certification-thinkpenguin-usb-with-atheros-chip
# https://wiki.debian.org/ath9k_htc/open_firmware # https://wiki.debian.org/ath9k_htc/open_firmware
mkdir -p /lib/firmware mkdir -p /lib/firmware
sudo install -b -o root -g root -m 0644 ../conf/firmware_htc-7010.fw /lib/firmware/htc_7010.fw install -b -o root -g root -m 0644 ../conf/firmware_htc-7010.fw /lib/firmware/htc_7010.fw
sudo install -b -o root -g root -m 0644 ../conf/firmware_htc-9271.fw /lib/firmware/htc_9271.fw install -b -o root -g root -m 0644 ../conf/firmware_htc-9271.fw /lib/firmware/htc_9271.fw
fi fi
sudo apt-get --assume-yes --force-yes install ${packages} apt-get --assume-yes --force-yes install ${packages}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
sudo apt-get update apt-get update
sudo apt-get --assume-yes --force-yes install ${packages} apt-get --assume-yes --force-yes install ${packages}
fi fi
#================================================= #=================================================
@ -150,8 +150,8 @@ if [[ ! -v ip6_net ]]; then # if ip6_net not set
ip6_addr=none ip6_addr=none
if [[ -e /tmp/.ynh-vpnclient-started ]]; then if [[ -e /tmp/.ynh-vpnclient-started ]]; then
vpnclient_ip6_net=$(sudo yunohost app setting vpnclient ip6_net 2>&1) vpnclient_ip6_net=$(sudo ynh_app_setting_set vpnclient ip6_net 2>&1)
vpnclient_ip6_addr=$(sudo yunohost app setting vpnclient ip6_addr 2>&1) vpnclient_ip6_addr=$(sudo ynh_app_setting_set vpnclient ip6_addr 2>&1)
if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then
ip6_net=${vpnclient_ip6_net} ip6_net=${vpnclient_ip6_net}
@ -196,61 +196,61 @@ ynh_app_setting_set $app vpnclient -v no
# INSTALL CUSTOM SCRIPTS # INSTALL CUSTOM SCRIPTS
#================================================= #=================================================
sudo install -o root -g root -m 0755 ../conf/iw_multissid /usr/local/bin/ 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/ install -o root -g root -m 0755 ../conf/iw_devices /usr/local/bin/
sudo install -o root -g root -m 0755 ../conf/iw_ssids /usr/local/bin/ install -o root -g root -m 0755 ../conf/iw_ssids /usr/local/bin/
sudo install -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/ install -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/
sudo install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/ install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/
#================================================= #=================================================
# COPY CONFIGS # COPY CONFIGS
#================================================= #=================================================
sudo mkdir -pm 0755 /var/log/nginx/ mkdir -pm 0755 /var/log/nginx/
sudo mkdir -pm 0755 /etc/dnsmasq.dhcpd/ mkdir -pm 0755 /etc/dnsmasq.dhcpd/
sudo chown root: /etc/dnsmasq.dhcpd/ chown root: /etc/dnsmasq.dhcpd/
sudo install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl? /etc/hostapd/ install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl? /etc/hostapd/
sudo install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.dhcpd/dhcpdv6.conf.tpl install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.dhcpd/dhcpdv6.conf.tpl
sudo install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.dhcpd/dhcpdv4.conf.tpl install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.dhcpd/dhcpdv4.conf.tpl
sudo install -b -o root -g root -m 0644 ../conf/nginx_wifiadmin.conf "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf" install -b -o root -g root -m 0644 ../conf/nginx_wifiadmin.conf "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
sudo install -b -o root -g root -m 0644 ../conf/phpfpm_wifiadmin.conf /etc/php5/fpm/pool.d/wifiadmin.conf install -b -o root -g root -m 0644 ../conf/phpfpm_wifiadmin.conf /etc/php5/fpm/pool.d/wifiadmin.conf
#================================================= #=================================================
# COPY WEB SOURCES # COPY WEB SOURCES
#================================================= #=================================================
sudo mkdir -pm 0755 /var/www/wifiadmin/ mkdir -pm 0755 /var/www/wifiadmin/
sudo cp -a ../sources/* /var/www/wifiadmin/ cp -a ../sources/* /var/www/wifiadmin/
sudo chown -R root: /var/www/wifiadmin/ chown -R root: /var/www/wifiadmin/
sudo chmod -R 0644 /var/www/wifiadmin/* chmod -R 0644 /var/www/wifiadmin/*
sudo find /var/www/wifiadmin/ -type d -exec chmod +x {} \; find /var/www/wifiadmin/ -type d -exec chmod +x {} \;
#================================================= #=================================================
# FIX CONFIGS # FIX CONFIGS
#================================================= #=================================================
## hostapd ## hostapd
sudo sed 's|^DAEMON_CONF=$|&/etc/hostapd/hostapd.conf|' -i /etc/init.d/hostapd sed 's|^DAEMON_CONF=$|&/etc/hostapd/hostapd.conf|' -i /etc/init.d/hostapd
## nginx ## nginx
sudo sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf" sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf" sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
sudo sed 's|<TPL:PHP_NAME>|wifiadmin|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf" sed 's|<TPL:PHP_NAME>|wifiadmin|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
## php-fpm ## php-fpm
sudo sed 's|<TPL:PHP_NAME>|wifiadmin|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf sed 's|<TPL:PHP_NAME>|wifiadmin|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf
sudo sed 's|<TPL:PHP_USER>|admin|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf sed 's|<TPL:PHP_USER>|admin|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf
sudo sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf
# Fix sources # Fix sources
sudo sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i /var/www/wifiadmin/config.php sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i /var/www/wifiadmin/config.php
# Copy init script # Copy init script
sudo install -o root -g root -m 0755 ../conf/ynh-hotspot /usr/local/bin/ install -o root -g root -m 0755 ../conf/ynh-hotspot /usr/local/bin/
sudo install -o root -g root -m 0644 ../conf/ynh-hotspot.service /etc/systemd/system/ install -o root -g root -m 0644 ../conf/ynh-hotspot.service /etc/systemd/system/
# Update firewall for DHCP # Update firewall for DHCP
yunohost firewall allow --no-upnp --ipv6 UDP 547 yunohost firewall allow --no-upnp --ipv6 UDP 547
@ -267,9 +267,9 @@ systemctl reload nginx
# Remove IPv6 address set if there is a VPN installed # Remove IPv6 address set if there is a VPN installed
if [[ $ip6_addr != none ]]; then if [[ $ip6_addr != none ]]; then
sudo ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/" ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"
if [[ "$?" -eq 0 ]]; then if [[ "$?" -eq 0 ]]; then
sudo ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null
fi fi
fi fi

View file

@ -39,18 +39,25 @@ firmware_nonfree=$(ynh_app_setting_get $app firmware_nonfree)
systemctl stop ynh-hotspot systemctl stop ynh-hotspot
systemctl disable ynh-hotspot systemctl disable ynh-hotspot
yunohost service remove ynh-hotspot yunohost service remove ynh-hotspot
sudo rm -f /etc/systemd/system/ynh-hotspot.service /usr/local/bin/ynh-hotspot ynh_secure_remove /etc/systemd/system/ynh-hotspot.service
sudo rm -f /tmp/.ynh-hotspot-* ynh_secure_remove /usr/local/bin/ynh-hotspot
for FILE in $(ls /tmp/.ynh-hotspot-*)
do
ynh_secure_remove "$FILE"
done
# Update firewall for DHCP # Update firewall for DHCP
sudo yunohost firewall disallow --ipv6 UDP 547 yunohost firewall disallow --ipv6 UDP 547
sudo yunohost firewall disallow UDP 67 yunohost firewall disallow UDP 67
# Remove confs # Remove confs
sudo rm -fr /etc/dnsmasq.dhcpd/ ynh_secure_remove /etc/dnsmasq.dhcpd/
sudo rm -f /etc/hostapd/hostapd.conf{.tpl?,} ynh_secure_remove /etc/nginx/conf.d/${domain}.d/wifiadmin.conf
sudo rm -f /etc/nginx/conf.d/${domain}.d/wifiadmin.conf ynh_secure_remove /etc/php5/fpm/pool.d/wifiadmin.conf
sudo rm -f /etc/php5/fpm/pool.d/wifiadmin.conf for FILE in $(ls /etc/hostapd/hostapd.conf{.tpl?,})
do
ynh_secure_remove "$FILE"
done
# Remove packages # Remove packages
if [[ $firmware_nonfree == yes ]]; then if [[ $firmware_nonfree == yes ]]; then
@ -60,15 +67,15 @@ else
# Remove free firmwares # Remove free firmwares
if ! dpkg -l firmware-atheros &> /dev/null; then if ! dpkg -l firmware-atheros &> /dev/null; then
sudo rm -f /lib/firmware/htc_7010.fw ynh_secure_remove /lib/firmware/htc_7010.fw
sudo rm -f /lib/firmware/htc_9271.fw ynh_secure_remove /lib/firmware/htc_9271.fw
fi fi
fi fi
sudo apt-get --assume-yes --force-yes remove ${packages} apt-get --assume-yes --force-yes remove ${packages}
# Restart services # Restart services
systemctl restart php5-fpm systemctl restart php5-fpm
systemctl reload nginx systemctl reload nginx
# Remove sources # Remove sources
sudo rm -rf /var/www/wifiadmin/ ynh_secure_remove /var/www/wifiadmin/

View file

@ -27,4 +27,4 @@ git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcomm
cd "${tmpdir}/scripts/" cd "${tmpdir}/scripts/"
bash ./upgrade bash ./upgrade
sudo rm -r "${tmpdir}/" ynh_secure_remove "${tmpdir}/"