Merge pull request #34 from keomabrun/master
using new helpers and script formatting
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
"fr": "Client VPN"
|
"fr": "Client VPN"
|
||||||
},
|
},
|
||||||
"url": "https://github.com/labriqueinternet/vpnclient_ynh",
|
"url": "https://github.com/labriqueinternet/vpnclient_ynh",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Julien Vaubourg",
|
"name": "Julien Vaubourg",
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
# Common variables
|
||||||
|
#
|
||||||
|
|
||||||
|
pkg_dependencies="php5-fpm sipcalc dnsutils openvpn curl fake-hwclock"
|
||||||
|
|
||||||
|
|
||||||
# Helper to start/stop/.. a systemd service from a yunohost context,
|
# Helper to start/stop/.. a systemd service from a yunohost context,
|
||||||
# *and* the systemd service itself needs to be able to run yunohost
|
# *and* the systemd service itself needs to be able to run yunohost
|
||||||
# commands.
|
# commands.
|
||||||
@@ -37,3 +40,4 @@ function ynh_systemctl()
|
|||||||
# Restore the old lock
|
# Restore the old lock
|
||||||
mv $LOCKFILE.bkp.$$ $LOCKFILE
|
mv $LOCKFILE.bkp.$$ $LOCKFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_abort_if_errors # Stop script if an error is detected
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
backup_dir="${1}/apps/vpnclient"
|
backup_dir="${1}/apps/vpnclient"
|
||||||
mkdir -p "${backup_dir}/"
|
mkdir -p "${backup_dir}/"
|
||||||
|
|
||||||
|
|||||||
108
scripts/install
108
scripts/install
@@ -17,44 +17,83 @@
|
|||||||
# 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=$([ "${VPNCLIENT_UPGRADE}" == 1 ] && echo true || echo false)
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=${1}
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
url_path=${2}
|
path_url=$YNH_APP_ARG_PATH
|
||||||
|
|
||||||
if ! $upgrade; then
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
source ./helpers
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check domain/path availability
|
#=================================================
|
||||||
ynh_webpath_register vpnclient $domain $url_path || ynh_die "problem on domain/path availability" 1
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Install packages
|
# Check destination directory
|
||||||
packages='php5-fpm sipcalc dnsutils openvpn curl fake-hwclock'
|
final_path="/var/www/$app"
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
|
|
||||||
sudo apt-get --assume-yes --force-yes install ${packages}
|
# Normalize the url path syntax
|
||||||
|
path_url=$(ynh_normalize_url_path "$path_url")
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
# Check web path availability
|
||||||
sudo apt-get update
|
ynh_webpath_available "$domain" "$path_url"
|
||||||
sudo apt-get --assume-yes --force-yes install ${packages}
|
# Register (book) web path
|
||||||
fi
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_app_setting_set "$app" domain "$domain"
|
||||||
|
ynh_app_setting_set "$app" final_path "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# This is an upgrade?
|
||||||
|
upgrade=$([ -z ${VPNCLIENT_UPGRADE+x} ] && echo true || echo false)
|
||||||
|
|
||||||
if ! $upgrade; then
|
if ! $upgrade; then
|
||||||
|
|
||||||
# Save arguments
|
# Save arguments
|
||||||
sudo yunohost app setting vpnclient service_enabled -v 0
|
ynh_app_setting_set $app service_enabled 0
|
||||||
sudo yunohost app setting vpnclient server_name -v none
|
ynh_app_setting_set $app server_name none
|
||||||
sudo yunohost app setting vpnclient server_port -v 1194
|
ynh_app_setting_set $app server_port 1194
|
||||||
sudo yunohost app setting vpnclient server_proto -v udp
|
ynh_app_setting_set $app server_proto udp
|
||||||
sudo yunohost app setting vpnclient ip6_addr -v none
|
ynh_app_setting_set $app ip6_addr none
|
||||||
sudo yunohost app setting vpnclient ip6_net -v none
|
ynh_app_setting_set $app ip6_net none
|
||||||
sudo yunohost app setting vpnclient login_user -v "${login_user}"
|
ynh_app_setting_set $app login_user "${login_user}"
|
||||||
sudo yunohost app setting vpnclient login_passphrase -v "${login_passphrase}"
|
ynh_app_setting_set $app login_passphrase "${login_passphrase}"
|
||||||
sudo yunohost app setting vpnclient dns0 -v 89.234.141.66
|
ynh_app_setting_set $app dns0 89.234.141.66
|
||||||
sudo yunohost app setting vpnclient dns1 -v 2001:913::8
|
ynh_app_setting_set $app dns1 2001:913::8
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -90,20 +129,25 @@ sudo find /var/www/vpnadmin/ -type d -exec chmod +x {} \;
|
|||||||
sudo mkdir -pm 0770 /etc/openvpn/keys/
|
sudo mkdir -pm 0770 /etc/openvpn/keys/
|
||||||
sudo chown root:admins /etc/openvpn/keys/
|
sudo chown root:admins /etc/openvpn/keys/
|
||||||
|
|
||||||
# Fix confs
|
#=================================================
|
||||||
## nginx
|
# NGINX CONFIGURATION
|
||||||
sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
|
#=================================================
|
||||||
|
|
||||||
|
sudo sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
|
||||||
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/vpnadmin/|g' -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
|
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/vpnadmin/|g' -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
|
||||||
sudo sed 's|<TPL:PHP_NAME>|vpnadmin|g' -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
|
sudo sed 's|<TPL:PHP_NAME>|vpnadmin|g' -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
|
||||||
|
|
||||||
## php-fpm
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo sed 's|<TPL:PHP_NAME>|vpnadmin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
sudo sed 's|<TPL:PHP_NAME>|vpnadmin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
||||||
sudo sed 's|<TPL:PHP_USER>|admin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
sudo sed 's|<TPL:PHP_USER>|admin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
||||||
sudo sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
sudo sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
||||||
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/vpnadmin/|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/vpnadmin/|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf
|
||||||
|
|
||||||
# Fix sources
|
# Fix sources
|
||||||
sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/vpnadmin/config.php
|
sudo sed "s|<TPL:NGINX_LOCATION>|${path_url}|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/
|
||||||
|
|||||||
@@ -17,11 +17,24 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
source ./helpers
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
source _common.sh
|
||||||
domain=$(sudo yunohost app setting vpnclient domain)
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# The End
|
# The End
|
||||||
ynh_systemctl stop ynh-vpnclient-checker.service
|
ynh_systemctl stop ynh-vpnclient-checker.service
|
||||||
sudo systemctl disable ynh-vpnclient-checker.service
|
sudo systemctl disable ynh-vpnclient-checker.service
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ ! -e _common.sh ]; then
|
||||||
|
# Fetch helpers file if not in current directory
|
||||||
|
cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
|
chmod a+rx _common.sh
|
||||||
|
fi
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
backup_dir="${1}/apps/vpnclient"
|
backup_dir="${1}/apps/vpnclient"
|
||||||
|
|
||||||
sudo mkdir -p /etc/openvpn/
|
sudo mkdir -p /etc/openvpn/
|
||||||
|
|||||||
@@ -1,16 +1,41 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ynh_setting() {
|
#=================================================
|
||||||
app=${1}
|
# GENERIC STARTING
|
||||||
setting=${2}
|
#=================================================
|
||||||
ynh_app_setting_get $app $setting
|
# IMPORT GENERIC HELPERS
|
||||||
}
|
#=================================================
|
||||||
|
|
||||||
source ./helpers
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
server_name=$(ynh_app_setting_get $app server_name)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_abort_if_up_to_date
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
domain=$(ynh_setting vpnclient domain)
|
|
||||||
path=$(ynh_setting vpnclient path)
|
|
||||||
server_name=$(ynh_setting vpnclient server_name)
|
|
||||||
|
|
||||||
sudo mkdir -m 0700 -p /var/cache/labriqueinternet/vpnclient/
|
sudo mkdir -m 0700 -p /var/cache/labriqueinternet/vpnclient/
|
||||||
sudo tar czf "/var/cache/labriqueinternet/vpnclient/rollback_$(date +%Y-%m-%d-%H%M%S).tgz" /etc/openvpn/ /etc/yunohost/apps/vpnclient/ &> /dev/null
|
sudo tar czf "/var/cache/labriqueinternet/vpnclient/rollback_$(date +%Y-%m-%d-%H%M%S).tgz" /etc/openvpn/ /etc/yunohost/apps/vpnclient/ &> /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user