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
|
||||
* Authentication based on certificates or login (or both)
|
||||
* 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
|
||||
* The internet provider can be a 3/4G connection with tethering
|
||||
* Web interface ([screenshot](https://raw.githubusercontent.com/jvaubourg/vpnclient_ynh/master/screenshot.png))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ynh-vpnclient
|
||||
# Required-Start: $network $remote_fs $syslog slapd
|
||||
# Required-Start: $network $remote_fs $syslog $all
|
||||
# Required-Stop: $network $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
@@ -16,14 +16,25 @@ has_nativeip6() {
|
||||
ip -6 route | grep -q default\ via
|
||||
}
|
||||
|
||||
has_hotspot_app() {
|
||||
yunohost app list -f hotspot --json | grep -q '"installed": true'
|
||||
}
|
||||
|
||||
has_ip6delegatedprefix() {
|
||||
[ "${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() {
|
||||
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
|
||||
echo "Already started"
|
||||
else
|
||||
echo "Starting..."
|
||||
echo "[vpnclient] Starting..."
|
||||
touch /tmp/.ynh-vpnclient-started
|
||||
|
||||
# Run openvpn
|
||||
if ! is_openvpn_running; then
|
||||
@@ -204,7 +216,7 @@ case "${1}" in
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(i=0 && false) || while [ $? -ne 0 ]; do
|
||||
i=0; false || while [ $? -ne 0 ]; do
|
||||
sleep 1 && (( i++ ))
|
||||
[ ${i} -gt 20 ] && stop_openvpn
|
||||
[ ${i} -gt 20 ] && exit 1
|
||||
@@ -232,18 +244,27 @@ case "${1}" in
|
||||
echo "Set IPv6 address"
|
||||
set_ip6addr
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update dynamic settings
|
||||
moulinette_set server_ip6 "${new_server_ip6}"
|
||||
moulinette_set ip6_gw "${new_ip6_gw}"
|
||||
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)
|
||||
echo "Stopping..."
|
||||
echo "[vpnclient] Stopping..."
|
||||
rm /tmp/.ynh-vpnclient-started
|
||||
|
||||
if ! has_hotspot_app && has_ip6delegatedprefix && is_ip6addr_set; then
|
||||
echo "Unset IPv6 address"
|
||||
@@ -260,12 +281,9 @@ case "${1}" in
|
||||
stop_openvpn
|
||||
fi
|
||||
|
||||
if [ -z "${litestop}" ]; then
|
||||
yunohost app list -f hotspot --json | grep -q '"installed": true'
|
||||
if [ $? -eq 0 ]; then
|
||||
if has_hotspot_app && ! is_hotspot_knowme; then
|
||||
service ynh-hotspot start
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
exitcode=0
|
||||
|
@@ -57,7 +57,11 @@ if [ ! $? -eq 0 ]; then
|
||||
fi
|
||||
|
||||
# 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
|
||||
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}"
|
||||
|
||||
# Install IPv6 scripts
|
||||
sudo install -b -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_expanded /usr/local/bin/
|
||||
sudo install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/
|
||||
|
||||
# Copy confs
|
||||
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
|
||||
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
|
||||
sudo yunohost app list -f hotspot --json | grep -q '"installed": true'
|
||||
if [ $? -eq 0 -a ! -z "${crt_server_ca_path}" ]; then
|
||||
if [ -e /tmp/.ynh-hotspot-started ]; then
|
||||
sudo service ynh-hotspot start
|
||||
fi
|
||||
|
||||
|
@@ -7,6 +7,7 @@ domain=$(sudo yunohost app setting vpnclient domain)
|
||||
sudo service ynh-vpnclient stop
|
||||
sudo yunohost service remove ynh-vpnclient
|
||||
sudo rm -f /etc/init.d/ynh-vpnclient
|
||||
sudo rm -f /tmp/.ynh-vpnclient-boot
|
||||
|
||||
# Remove confs
|
||||
sudo rm -f /etc/openvpn/client.conf{.tpl,}
|
||||
@@ -29,6 +30,7 @@ sudo userdel -f vpnadmin
|
||||
|
||||
# Remove packets
|
||||
# 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
|
||||
|
@@ -9,7 +9,7 @@ function moulinette_set($var, $value) {
|
||||
}
|
||||
|
||||
function stop_service() {
|
||||
exec('sudo service ynh-vpnclient litestop');
|
||||
exec('sudo service ynh-vpnclient stop');
|
||||
}
|
||||
|
||||
function start_service() {
|
||||
@@ -94,7 +94,7 @@ dispatch_put('/settings', function() {
|
||||
}
|
||||
|
||||
$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_addr = ipv6_compressed($ip6_addr);
|
||||
|
Reference in New Issue
Block a user