Problem with services order fixed
This commit is contained in:
@@ -16,7 +16,6 @@ VPN Client app for [YunoHost](http://yunohost.org/).
|
|||||||
* Port selection, with UDP or TCP
|
* Port selection, with UDP or TCP
|
||||||
* Authentication based on certificates or login (or both)
|
* Authentication based on certificates or login (or both)
|
||||||
* IPv6 compliant (with a delegated prefix)
|
* IPv6 compliant (with a delegated prefix)
|
||||||
* Set an IPv6 from your delegated prefix (*prefix::1*) on the server, to use for the AAAA records
|
* Set an IPv6 from your delegated prefix (*prefix::42*) on the server, to use for the AAAA records
|
||||||
* Use native IPv6 if available for creating the tunnel
|
* Use native IPv6 if available for creating the tunnel
|
||||||
* The internet provider can be a 3/4G connection with tethering
|
|
||||||
* Web interface ([screenshot](https://raw.githubusercontent.com/jvaubourg/vpnclient_ynh/master/screenshot.png))
|
* Web interface ([screenshot](https://raw.githubusercontent.com/jvaubourg/vpnclient_ynh/master/screenshot.png))
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: ynh-vpnclient
|
# Provides: ynh-vpnclient
|
||||||
# Required-Start: $network $remote_fs $syslog slapd
|
# Required-Start: $network $remote_fs $syslog $all
|
||||||
# Required-Stop: $network $remote_fs $syslog
|
# Required-Stop: $network $remote_fs $syslog
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
# Default-Stop: 0 1 6
|
# Default-Stop: 0 1 6
|
||||||
@@ -16,14 +16,25 @@ has_nativeip6() {
|
|||||||
ip -6 route | grep -q default\ via
|
ip -6 route | grep -q default\ via
|
||||||
}
|
}
|
||||||
|
|
||||||
has_hotspot_app() {
|
|
||||||
yunohost app list -f hotspot --json | grep -q '"installed": true'
|
|
||||||
}
|
|
||||||
|
|
||||||
has_ip6delegatedprefix() {
|
has_ip6delegatedprefix() {
|
||||||
[ "${ynh_ip6_addr}" != none ]
|
[ "${ynh_ip6_addr}" != none ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_hotspot_app() {
|
||||||
|
[ -e /tmp/.ynh-hotspot-started ]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_hotspot_knowme() {
|
||||||
|
value=$(yunohost app setting hotspot vpnclient)
|
||||||
|
|
||||||
|
if [[ "${value}" =~ "An instance is already running" ]]; then
|
||||||
|
echo "${value}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "${value}" == yes ]
|
||||||
|
}
|
||||||
|
|
||||||
is_ip6addr_set() {
|
is_ip6addr_set() {
|
||||||
ip address show dev tun0 2> /dev/null | grep -q "${ynh_ip6_addr}/128"
|
ip address show dev tun0 2> /dev/null | grep -q "${ynh_ip6_addr}/128"
|
||||||
}
|
}
|
||||||
@@ -192,7 +203,8 @@ case "${1}" in
|
|||||||
if is_running; then
|
if is_running; then
|
||||||
echo "Already started"
|
echo "Already started"
|
||||||
else
|
else
|
||||||
echo "Starting..."
|
echo "[vpnclient] Starting..."
|
||||||
|
touch /tmp/.ynh-vpnclient-started
|
||||||
|
|
||||||
# Run openvpn
|
# Run openvpn
|
||||||
if ! is_openvpn_running; then
|
if ! is_openvpn_running; then
|
||||||
@@ -204,7 +216,7 @@ case "${1}" in
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(i=0 && false) || while [ $? -ne 0 ]; do
|
i=0; false || while [ $? -ne 0 ]; do
|
||||||
sleep 1 && (( i++ ))
|
sleep 1 && (( i++ ))
|
||||||
[ ${i} -gt 20 ] && stop_openvpn
|
[ ${i} -gt 20 ] && stop_openvpn
|
||||||
[ ${i} -gt 20 ] && exit 1
|
[ ${i} -gt 20 ] && exit 1
|
||||||
@@ -232,18 +244,27 @@ case "${1}" in
|
|||||||
echo "Set IPv6 address"
|
echo "Set IPv6 address"
|
||||||
set_ip6addr
|
set_ip6addr
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Update dynamic settings
|
# Update dynamic settings
|
||||||
moulinette_set server_ip6 "${new_server_ip6}"
|
moulinette_set server_ip6 "${new_server_ip6}"
|
||||||
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 hotspot if needed
|
||||||
|
if has_hotspot_app && ! is_hotspot_knowme; then
|
||||||
|
service ynh-hotspot start
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restart php5-fpm at the first start (it needs to be restarted after the slapd start)
|
||||||
|
if [ ! -e /tmp/.ynh-vpnclient-boot ]; then
|
||||||
|
touch /tmp/.ynh-vpnclient-boot
|
||||||
|
service php5-fpm restart
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
litestop)
|
|
||||||
litestop=1
|
|
||||||
;&
|
|
||||||
stop)
|
stop)
|
||||||
echo "Stopping..."
|
echo "[vpnclient] Stopping..."
|
||||||
|
rm /tmp/.ynh-vpnclient-started
|
||||||
|
|
||||||
if ! has_hotspot_app && has_ip6delegatedprefix && is_ip6addr_set; then
|
if ! has_hotspot_app && has_ip6delegatedprefix && is_ip6addr_set; then
|
||||||
echo "Unset IPv6 address"
|
echo "Unset IPv6 address"
|
||||||
@@ -260,12 +281,9 @@ case "${1}" in
|
|||||||
stop_openvpn
|
stop_openvpn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${litestop}" ]; then
|
if has_hotspot_app && ! is_hotspot_knowme; then
|
||||||
yunohost app list -f hotspot --json | grep -q '"installed": true'
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
service ynh-hotspot start
|
service ynh-hotspot start
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
exitcode=0
|
exitcode=0
|
||||||
|
@@ -57,7 +57,11 @@ if [ ! $? -eq 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
sudo apt-get --assume-yes --force-yes install openvpn php5-fpm sipcalc
|
#sudo apt-get update
|
||||||
|
sudo apt-get --assume-yes --force-yes install openvpn php5-fpm
|
||||||
|
|
||||||
|
# Extra packages
|
||||||
|
sudo apt-get --assume-yes --force-yes install sipcalc
|
||||||
|
|
||||||
# Save arguments
|
# Save arguments
|
||||||
sudo yunohost app setting vpnclient server_name -v "${server_name}"
|
sudo yunohost app setting vpnclient server_name -v "${server_name}"
|
||||||
@@ -69,8 +73,8 @@ sudo yunohost app setting vpnclient login_user -v "${login_user}"
|
|||||||
sudo yunohost app setting vpnclient login_passphrase -v "${login_passphrase}"
|
sudo yunohost app setting vpnclient login_passphrase -v "${login_passphrase}"
|
||||||
|
|
||||||
# Install IPv6 scripts
|
# Install IPv6 scripts
|
||||||
sudo install -b -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/
|
sudo install -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/
|
||||||
sudo install -b -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/
|
sudo install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/
|
||||||
|
|
||||||
# Copy confs
|
# Copy confs
|
||||||
sudo install -b -o root -g root -m 0644 ../conf/openvpn_client.conf.tpl /etc/openvpn/client.conf.tpl
|
sudo install -b -o root -g root -m 0644 ../conf/openvpn_client.conf.tpl /etc/openvpn/client.conf.tpl
|
||||||
@@ -155,10 +159,9 @@ sudo service nginx reload
|
|||||||
# Update SSO for vpnadmin
|
# Update SSO for vpnadmin
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
# Restart hotspot service if installed 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
|
||||||
sudo yunohost app list -f hotspot --json | grep -q '"installed": true'
|
if [ -e /tmp/.ynh-hotspot-started ]; then
|
||||||
if [ $? -eq 0 -a ! -z "${crt_server_ca_path}" ]; then
|
|
||||||
sudo service ynh-hotspot start
|
sudo service ynh-hotspot start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ domain=$(sudo yunohost app setting vpnclient domain)
|
|||||||
sudo service ynh-vpnclient stop
|
sudo service ynh-vpnclient stop
|
||||||
sudo yunohost service remove ynh-vpnclient
|
sudo yunohost service remove ynh-vpnclient
|
||||||
sudo rm -f /etc/init.d/ynh-vpnclient
|
sudo rm -f /etc/init.d/ynh-vpnclient
|
||||||
|
sudo rm -f /tmp/.ynh-vpnclient-boot
|
||||||
|
|
||||||
# Remove confs
|
# Remove confs
|
||||||
sudo rm -f /etc/openvpn/client.conf{.tpl,}
|
sudo rm -f /etc/openvpn/client.conf{.tpl,}
|
||||||
@@ -29,6 +30,7 @@ sudo userdel -f vpnadmin
|
|||||||
|
|
||||||
# Remove packets
|
# Remove packets
|
||||||
# The yunohost policy is currently to not uninstall packets (dependency problems)
|
# The yunohost policy is currently to not uninstall packets (dependency problems)
|
||||||
## sudo apt-get --assume-yes --force-yes remove openvpn php5-fpm sipcalc
|
## sudo apt-get --assume-yes --force-yes remove openvpn php5-fpm
|
||||||
|
## sudo apt-get --assume-yes --force-yes remove sipcalc
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@@ -9,7 +9,7 @@ function moulinette_set($var, $value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stop_service() {
|
function stop_service() {
|
||||||
exec('sudo service ynh-vpnclient litestop');
|
exec('sudo service ynh-vpnclient stop');
|
||||||
}
|
}
|
||||||
|
|
||||||
function start_service() {
|
function start_service() {
|
||||||
@@ -94,7 +94,7 @@ dispatch_put('/settings', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ip6_blocs = explode(':', $ip6_net);
|
$ip6_blocs = explode(':', $ip6_net);
|
||||||
$ip6_addr = "${ip6_blocs[0]}:${ip6_blocs[1]}:${ip6_blocs[2]}:${ip6_blocs[3]}:${ip6_blocs[4]}:${ip6_blocs[5]}:${ip6_blocs[6]}:1";
|
$ip6_addr = "${ip6_blocs[0]}:${ip6_blocs[1]}:${ip6_blocs[2]}:${ip6_blocs[3]}:${ip6_blocs[4]}:${ip6_blocs[5]}:${ip6_blocs[6]}:42";
|
||||||
|
|
||||||
$ip6_net = ipv6_compressed($ip6_net);
|
$ip6_net = ipv6_compressed($ip6_net);
|
||||||
$ip6_addr = ipv6_compressed($ip6_addr);
|
$ip6_addr = ipv6_compressed($ip6_addr);
|
||||||
|
Reference in New Issue
Block a user