Ready for Jessie (+ some improvements)
This commit is contained in:
@@ -24,10 +24,5 @@ This YunoHost app is a part of the "[La Brique Internet](http://labriqueinter.ne
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
This app works with a non-stable version of YunoHost.
|
* Debian Jessie
|
||||||
|
* YunoHost >= 2.2.0
|
||||||
Until this version is available (coming soon!) as an official stable release, you need to execute some commands before installing this app:
|
|
||||||
|
|
||||||
# systemctl stop bind9
|
|
||||||
# systemctl disable bind9
|
|
||||||
# apt-get install dnsmasq
|
|
||||||
|
|||||||
@@ -33,12 +33,17 @@ has_hotspot_app() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_hotspot_knowme() {
|
is_hotspot_knowme() {
|
||||||
value=$(yunohost app setting hotspot vpnclient)
|
gotcha=0
|
||||||
|
|
||||||
if [[ "${value}" =~ "An instance is already running" ]]; then
|
while [ "${gotcha}" -eq 0 ]; do
|
||||||
echo "${value}" >&2
|
value=$(yunohost app setting hotspot vpnclient)
|
||||||
exit 1
|
|
||||||
fi
|
if [[ "${value}" =~ "An instance is already running" ]]; then
|
||||||
|
sleep $(($((RANDOM%5)) + 1))
|
||||||
|
else
|
||||||
|
gotcha=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
[ "${value}" == yes ]
|
[ "${value}" == yes ]
|
||||||
}
|
}
|
||||||
@@ -58,7 +63,7 @@ is_serverip6route_set() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_openvpn_running() {
|
is_openvpn_running() {
|
||||||
systemctl is-active openvpn@client.service --quiet &> /dev/null
|
systemctl is-active openvpn@client.service &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
is_running() {
|
is_running() {
|
||||||
@@ -117,7 +122,7 @@ start_openvpn() {
|
|||||||
sed 's|^<TPL:LOGIN_COMMENT>||' -i /etc/openvpn/client.conf
|
sed 's|^<TPL:LOGIN_COMMENT>||' -i /etc/openvpn/client.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl start openvpn@client.service --quiet
|
systemctl start openvpn@client.service
|
||||||
}
|
}
|
||||||
|
|
||||||
## Unsetters
|
## Unsetters
|
||||||
@@ -135,20 +140,24 @@ unset_serverip6route() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop_openvpn() {
|
stop_openvpn() {
|
||||||
systemctl stop openvpn.service --quiet
|
systemctl stop openvpn.service
|
||||||
}
|
}
|
||||||
|
|
||||||
## Tools
|
## Tools
|
||||||
|
|
||||||
moulinette_get() {
|
moulinette_get() {
|
||||||
var=${1}
|
var=${1}
|
||||||
|
gotcha=0
|
||||||
|
|
||||||
value=$(yunohost app setting vpnclient "${var}")
|
while [ "${gotcha}" -eq 0 ]; do
|
||||||
|
value=$(yunohost app setting vpnclient "${var}")
|
||||||
|
|
||||||
if [[ "${value}" =~ "An instance is already running" ]]; then
|
if [[ "${value}" =~ "An instance is already running" ]]; then
|
||||||
echo "${value}" >&2
|
sleep $(($((RANDOM%5)) + 1))
|
||||||
exit 1
|
else
|
||||||
fi
|
gotcha=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "${value}"
|
echo "${value}"
|
||||||
}
|
}
|
||||||
@@ -170,7 +179,7 @@ if [ "$1" != restart ]; then
|
|||||||
# Restart php5-fpm at the first start (it needs to be restarted after the slapd start)
|
# Restart php5-fpm at the first start (it needs to be restarted after the slapd start)
|
||||||
if [ ! -e /tmp/.ynh-vpnclient-boot ]; then
|
if [ ! -e /tmp/.ynh-vpnclient-boot ]; then
|
||||||
touch /tmp/.ynh-vpnclient-boot
|
touch /tmp/.ynh-vpnclient-boot
|
||||||
systemctl restart php5-fpm --quiet
|
systemctl restart php5-fpm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check configuration consistency
|
# Check configuration consistency
|
||||||
@@ -275,13 +284,9 @@ case "${1}" in
|
|||||||
moulinette_set ip6_gw "${new_ip6_gw}"
|
moulinette_set ip6_gw "${new_ip6_gw}"
|
||||||
moulinette_set wired_device "${new_wired_device}"
|
moulinette_set wired_device "${new_wired_device}"
|
||||||
|
|
||||||
# Restart dhcpd
|
# Fix configuration
|
||||||
systemctl stop bind9 --quiet &> /dev/null
|
|
||||||
systemctl restart dnsmasq --quiet
|
|
||||||
|
|
||||||
# Restart hotspot if needed
|
|
||||||
if has_hotspot_app && ! is_hotspot_knowme; then
|
if has_hotspot_app && ! is_hotspot_knowme; then
|
||||||
systemctl start ynh-hotspot --quiet
|
ynh-hotspot start
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -310,11 +315,10 @@ case "${1}" in
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Fix configuration
|
||||||
if has_hotspot_app && is_hotspot_knowme; then
|
if has_hotspot_app && is_hotspot_knowme; then
|
||||||
systemctl start ynh-hotspot --quiet
|
ynh-hotspot start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl restart dnsmasq --quiet
|
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
$0 stop
|
$0 stop
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
Description=YunoHost VPN Client.
|
Description=YunoHost VPN Client.
|
||||||
Requires=network.target
|
Requires=network.target
|
||||||
After=network.target
|
After=network.target
|
||||||
|
Wants=ynh-hotspot.service
|
||||||
|
Before=ynh-hotspot.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/local/bin/ynh-vpnclient start
|
ExecStart=/usr/local/bin/ynh-vpnclient start
|
||||||
ExecRestart=/usr/local/bin/ynh-vpnclient restart
|
|
||||||
ExecStop=/usr/local/bin/ynh-vpnclient stop
|
ExecStop=/usr/local/bin/ynh-vpnclient stop
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
Alias=ynh-vpnclient.service
|
|
||||||
|
|||||||
@@ -163,33 +163,30 @@ sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/vpnadmin/config.php
|
|||||||
|
|
||||||
# Copy init script
|
# Copy init script
|
||||||
sudo install -o root -g root -m 0755 ../conf/ynh-vpnclient /usr/local/bin/
|
sudo install -o root -g root -m 0755 ../conf/ynh-vpnclient /usr/local/bin/
|
||||||
sudo install -o root -g root -m 0755 ../conf/ynh-vpnclient.service /lib/systemd/system/ynh-vpnclient.service
|
sudo install -o root -g root -m 0644 ../conf/ynh-vpnclient.service /etc/systemd/system/
|
||||||
|
|
||||||
# Set default inits
|
# Set default inits
|
||||||
# The openvpn configuration is modified before the start, so the service is disabled by default
|
# The boot order of these services are important, so they are disabled by default
|
||||||
# and the ynh-vpnclient service handles it.
|
# and the ynh-vpnclient service handles them.
|
||||||
sudo yunohost service add openvpn
|
sudo systemctl disable openvpn
|
||||||
sudo yunohost service stop openvpn
|
sudo systemctl stop openvpn
|
||||||
sudo yunohost service disable openvpn
|
|
||||||
|
|
||||||
sudo yunohost service add php5-fpm
|
sudo systemctl enable php5-fpm
|
||||||
sudo yunohost service enable php5-fpm
|
sudo systemctl restart php5-fpm
|
||||||
|
|
||||||
sudo yunohost service add ynh-vpnclient
|
sudo systemctl reload nginx
|
||||||
sudo yunohost service enable ynh-vpnclient
|
|
||||||
sudo systemctl start ynh-vpnclient --quiet
|
|
||||||
|
|
||||||
sudo systemctl reload nginx --quiet
|
sudo systemctl enable ynh-vpnclient
|
||||||
|
sudo systemctl start ynh-vpnclient
|
||||||
|
|
||||||
# Update SSO for vpnadmin
|
# Update SSO for vpnadmin
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
# Restart hotspot service if installed (and started) to change NAT configuration (now on tun0)
|
# Restart hotspot service if installed (and started) to change NAT configuration (now on tun0)
|
||||||
# A new start will fix the interface without unsetting all stuff
|
# A new start will fix the interface without unsetting all stuff
|
||||||
if [ -e /tmp/.ynh-hotspot-started ]; then
|
#if [ -e /tmp/.ynh-hotspot-started ]; then
|
||||||
sudo systemctl restart ynh-hotspot --quiet
|
# sudo ynh-hotspot start
|
||||||
sudo systemctl restart dnsmasq --quiet
|
#fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Check configuration consistency
|
# Check configuration consistency
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,9 @@
|
|||||||
domain=$(sudo yunohost app setting vpnclient domain)
|
domain=$(sudo yunohost app setting vpnclient domain)
|
||||||
|
|
||||||
# The End
|
# The End
|
||||||
sudo systemctl stop ynh-vpnclient --quiet
|
sudo systemctl stop ynh-vpnclient
|
||||||
sudo systemctl disable ynh-vpnclient --quiet
|
sudo systemctl disable ynh-vpnclient
|
||||||
sudo yunohost service remove ynh-vpnclient
|
sudo rm -f /etc/systemd/system/ynh-vpnclient.service /usr/local/bin/ynh-vpnclient
|
||||||
sudo rm -f /lib/systemd/system/ynh-vpnclient.service /usr/local/bin/ynh-vpnclient
|
|
||||||
sudo rm -f /tmp/.ynh-vpnclient-*
|
sudo rm -f /tmp/.ynh-vpnclient-*
|
||||||
|
|
||||||
# Remove confs
|
# Remove confs
|
||||||
@@ -36,9 +35,8 @@ sudo rm -f /etc/php5/fpm/pool.d/vpnadmin.conf
|
|||||||
sudo rm -rf /etc/openvpn/keys/
|
sudo rm -rf /etc/openvpn/keys/
|
||||||
|
|
||||||
# Restart services
|
# Restart services
|
||||||
sudo yunohost service stop php5-fpm
|
sudo systemctl restart php5-fpm
|
||||||
sudo yunohost service start php5-fpm
|
sudo systemctl reload nginx
|
||||||
sudo systemctl reload nginx --quiet
|
|
||||||
|
|
||||||
# Remove sources
|
# Remove sources
|
||||||
sudo rm -rf /var/www/vpnadmin/
|
sudo rm -rf /var/www/vpnadmin/
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ function start_service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function service_status() {
|
function service_status() {
|
||||||
exec('sudo systemctl is-active ynh-vpnclient', $output);
|
exec('sudo ynh-vpnclient status', $output);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user