From 8aab3c7dd291f865d4eaf3826e79578765283113 Mon Sep 17 00:00:00 2001 From: agentcobra Date: Fri, 23 Mar 2018 09:23:57 +0100 Subject: [PATCH 01/16] Package improvement (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix manifest * fix tabs * add Services section in manifest * Fix invalid JSON open an issue https://dev.yunohost.org/issues/1097 * fix "Impossible de satisfaire les pré-requis pour vpnclient : Paquet « yunohost-moulinette » inconnu" * finalisation manifest.json et harmonisation avec https://yunohost.org/#/packaging_apps_manifest_fr * ajout de du CI avec .travis.yml * Update README.md * lifting manifest.json * remove exit 0 from scrits and add .gitignore * fix lint error with exit * fix #31 * refix #31 --- .gitignore | 3 +++ .travis.yml | 8 ++++++++ README.md | 1 + manifest.json | 30 ++++++++++++++++++++++-------- scripts/backup | 1 - scripts/install | 4 +--- scripts/prerequisites | 8 -------- scripts/remove | 1 - scripts/restore | 1 - scripts/upgrade | 2 -- 10 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 .gitignore create mode 100644 .travis.yml delete mode 100644 scripts/prerequisites diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1cfaba4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Created from https://github.com/YunoHost/example_ynh/blob/master/.gitignore +*~ +*.sw[op] \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..83744ac --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: php + +before_script: + - git clone --depth 1 git://github.com/YunoHost/package_linter ../package_linter && cd ../package_linter + - mv ../vpnclient_ynh vpnclient_ynh + +script: + - ./package_linter.py vpnclient_ynh \ No newline at end of file diff --git a/README.md b/README.md index 9a668d7..d7d3ebc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # VPN Client +[![Build Status](https://travis-ci.org/labriqueinternet/vpnclient_ynh.svg?branch=master)](https://travis-ci.org/labriqueinternet/vpnclient_ynh) ## Overview VPN Client app for [YunoHost](http://yunohost.org/). diff --git a/manifest.json b/manifest.json index 902fa42..d27b67a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,32 +1,46 @@ { "name": "VPN Client", "id": "vpnclient", + "packaging_format": 1, "description": { "en": "VPN Client", "fr": "Client VPN" }, - "license": "AGPL-3", - "developer": { + "url": "https://github.com/labriqueinternet/vpnclient_ynh", + "version": "1.0.0", + "license": "AGPL-3.0", + "maintainer": { "name": "Julien Vaubourg", "email": "julien@vaubourg.com", "url": "http://julien.vaubourg.com" }, - "multi_instance": "false", + "requirements": { + "yunohost": ">= 2.2.0", + "moulinette": ">= 2.4.0" + }, + "multi_instance": false, + "services": [ + "nginx", + "php5-fpm", + "ynh-vpnclient" + ], "arguments": { - "install" : [ + "install": [ { "name": "domain", + "type": "domain", "ask": { - "en": "Choose a domain for the web administration", - "fr": "Choisissez un domaine pour l'administration web" + "en": "Choose a domain for the web administration", + "fr": "Choisissez un domaine pour l'administration web" }, "example": "domain.org" }, { "name": "path", + "type": "path", "ask": { - "en": "Choose a path for the web administration", - "fr": "Choisissez un chemin pour l'administration web" + "en": "Choose a path for the web administration", + "fr": "Choisissez un chemin pour l'administration web" }, "example": "/vpnadmin", "default": "/vpnadmin" diff --git a/scripts/backup b/scripts/backup index 43b6047..e314070 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,4 +6,3 @@ mkdir -p "${backup_dir}/" sudo cp -a /etc/openvpn/keys/ "${backup_dir}/" sudo cp -a /etc/openvpn/client.conf.tpl "${backup_dir}/" -exit 0 diff --git a/scripts/install b/scripts/install index b7747be..efbde6a 100644 --- a/scripts/install +++ b/scripts/install @@ -26,11 +26,10 @@ url_path=${2} if ! $upgrade; then source ./helpers - source ./prerequisites fi # Check domain/path availability -ynh_webpath_register vpnclient $domain $url_path || exit 1 +ynh_webpath_register vpnclient $domain $url_path || ynh_die "problem on domain/path availability" 1 # Install packages packages='php5-fpm sipcalc dnsutils openvpn curl' @@ -150,4 +149,3 @@ fi sudo yunohost app ssowatconf -exit 0 diff --git a/scripts/prerequisites b/scripts/prerequisites deleted file mode 100644 index 4b18fc3..0000000 --- a/scripts/prerequisites +++ /dev/null @@ -1,8 +0,0 @@ -# Source me - -# Check YunoHost version (firewall hook in Moulinette) -ynh_version=$(sudo dpkg -l yunohost | grep ii | awk '{ print $3 }' | sed 's/\.//g') - -if [ "${ynh_version}" -lt 240 ]; then - echo "WARN: You need a YunoHost's version equals or greater than 2.4.0 for activating the firewalling" >&2 -fi diff --git a/scripts/remove b/scripts/remove index 1d92f61..011c908 100644 --- a/scripts/remove +++ b/scripts/remove @@ -50,4 +50,3 @@ sudo systemctl reload nginx # Remove sources sudo rm -rf /var/www/vpnadmin/ -exit 0 diff --git a/scripts/restore b/scripts/restore index 7b88ea1..59f9f4b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -18,4 +18,3 @@ bash ./upgrade sudo rm -r "${tmpdir}/" -exit 0 diff --git a/scripts/upgrade b/scripts/upgrade index 6d4dd7b..f5a8567 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,7 +8,6 @@ ynh_setting() { } source ./helpers -source ./prerequisites domain=$(ynh_setting vpnclient domain) path=$(ynh_setting vpnclient path) @@ -44,4 +43,3 @@ fi ynh_systemctl start ynh-vpnclient -exit 0 From c9d75373877b9e75b5bbbec180bfe3179f2c8ed6 Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Fri, 23 Mar 2018 10:29:24 +0100 Subject: [PATCH 02/16] cr: Update notifications settings --- .travis.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83744ac..867ad1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,13 @@ language: php - before_script: - git clone --depth 1 git://github.com/YunoHost/package_linter ../package_linter && cd ../package_linter - mv ../vpnclient_ynh vpnclient_ynh - script: - - ./package_linter.py vpnclient_ynh \ No newline at end of file + - ./package_linter.py vpnclient_ynh +notifications: + email: false + irc: + on_success: always + on_failure: always + channels: + - "irc.geeknode.org#labriqueinter.net-dev" From b34644c72963151b636455aa7ac472df866dfbd2 Mon Sep 17 00:00:00 2001 From: agentcobra Date: Fri, 6 Apr 2018 13:09:02 +0200 Subject: [PATCH 03/16] Update upgrade quick fix for ci building failling --- scripts/upgrade | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f5a8567..536c496 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,8 +3,7 @@ ynh_setting() { app=${1} setting=${2} - - sudo grep "^${setting}:" "/etc/yunohost/apps/${app}/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$// + ynh_app_setting_get $app $setting } source ./helpers From 5654b6d0b266b14a5432bcd2f3e8428ef0f53ac9 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Fri, 6 Apr 2018 14:13:04 +0200 Subject: [PATCH 04/16] [fix] ntpd blocked cause firewall to strict --- conf/ynh-vpnclient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/ynh-vpnclient b/conf/ynh-vpnclient index 910e282..36a97e8 100644 --- a/conf/ynh-vpnclient +++ b/conf/ynh-vpnclient @@ -199,7 +199,7 @@ stop_openvpn() { sync_time() { systemctl stop ntp - ntpd -qg &> /dev/null + timeout 20 ntpd -qg &> /dev/null systemctl start ntp } From a642a010291a010ee6d88ee6473fc34d1654d5a2 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Fri, 6 Apr 2018 12:41:20 +0200 Subject: [PATCH 05/16] [fix] Add fake-hwclock to avoid RTC 1970 date A20 Allwinner seems to have a RTC but i think this one can't work when the board is shutdown (during several minutes/hours/days ?). This package register the last date and set it early in the boot process. --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index efbde6a..269c1e9 100644 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,7 @@ fi ynh_webpath_register vpnclient $domain $url_path || ynh_die "problem on domain/path availability" 1 # Install packages -packages='php5-fpm sipcalc dnsutils openvpn curl' +packages='php5-fpm sipcalc dnsutils openvpn curl fake-hwclock' export DEBIAN_FRONTEND=noninteractive sudo apt-get --assume-yes --force-yes install ${packages} From 35f38ec86ca6577d7901cf458118fcf0ec6cfa65 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Fri, 6 Apr 2018 12:49:22 +0200 Subject: [PATCH 06/16] [enh] Update version number --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index d27b67a..e7f76bf 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Client VPN" }, "url": "https://github.com/labriqueinternet/vpnclient_ynh", - "version": "1.0.0", + "version": "1.0.1", "license": "AGPL-3.0", "maintainer": { "name": "Julien Vaubourg", From 809dc19c800a86dbf691f598583444cb51afeb7c Mon Sep 17 00:00:00 2001 From: Keoma Brun Date: Fri, 6 Apr 2018 23:55:12 +0200 Subject: [PATCH 07/16] using new helpers and script formatting --- manifest.json | 2 +- scripts/{helpers => _common.sh} | 14 ++-- scripts/backup | 8 +++ scripts/install | 120 ++++++++++++++++++++++---------- scripts/remove | 27 +++++-- scripts/restore | 19 +++++ scripts/upgrade | 43 +++++++++--- 7 files changed, 173 insertions(+), 60 deletions(-) rename scripts/{helpers => _common.sh} (88%) diff --git a/manifest.json b/manifest.json index e7f76bf..f68ff0b 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Client VPN" }, "url": "https://github.com/labriqueinternet/vpnclient_ynh", - "version": "1.0.1", + "version": "1.1.0", "license": "AGPL-3.0", "maintainer": { "name": "Julien Vaubourg", diff --git a/scripts/helpers b/scripts/_common.sh similarity index 88% rename from scripts/helpers rename to scripts/_common.sh index f91730f..8c82ee9 100644 --- a/scripts/helpers +++ b/scripts/_common.sh @@ -1,12 +1,15 @@ #!/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, # *and* the systemd service itself needs to be able to run yunohost # commands. -# +# # Hence the need to release the lock during the operation # # usage : ynh_systemctl yolo restart @@ -24,7 +27,7 @@ function ynh_systemctl() # Save and release the lock... cp $LOCKFILE $LOCKFILE.bkp.$$ rm $LOCKFILE - + # Wait for the end of the action wait $SYSCTLACTION @@ -37,3 +40,4 @@ function ynh_systemctl() # Restore the old lock mv $LOCKFILE.bkp.$$ $LOCKFILE } + diff --git a/scripts/backup b/scripts/backup index e314070..5b857c3 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,5 +1,13 @@ #!/bin/bash +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_abort_if_errors # Stop script if an error is detected + +#================================================= + backup_dir="${1}/apps/vpnclient" mkdir -p "${backup_dir}/" diff --git a/scripts/install b/scripts/install index 269c1e9..ed504f8 100644 --- a/scripts/install +++ b/scripts/install @@ -1,60 +1,99 @@ #!/bin/bash -# VPN Client app for YunoHost +# VPN Client app for YunoHost # Copyright (C) 2015 Julien Vaubourg # Contribute at https://github.com/labriqueinternet/vpnclient_ynh -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. -# +# # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# 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 -domain=${1} -url_path=${2} +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH -if ! $upgrade; then - source ./helpers -fi +app=$YNH_APP_INSTANCE_NAME -# 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 -packages='php5-fpm sipcalc dnsutils openvpn curl fake-hwclock' -export DEBIAN_FRONTEND=noninteractive +# Check destination directory +final_path="/var/www/$app" +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 - sudo apt-get update - sudo apt-get --assume-yes --force-yes install ${packages} -fi +# Check web path availability +ynh_webpath_available "$domain" "$path_url" +# Register (book) web path +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 # Save arguments - sudo yunohost app setting vpnclient service_enabled -v 0 - sudo yunohost app setting vpnclient server_name -v none - sudo yunohost app setting vpnclient server_port -v 1194 - sudo yunohost app setting vpnclient server_proto -v udp - sudo yunohost app setting vpnclient ip6_addr -v none - sudo yunohost app setting vpnclient ip6_net -v none - 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 dns0 -v 89.234.141.66 - sudo yunohost app setting vpnclient dns1 -v 2001:913::8 + ynh_app_setting_set $app service_enabled 0 + ynh_app_setting_set $app server_name none + ynh_app_setting_set $app server_port 1194 + ynh_app_setting_set $app server_proto udp + ynh_app_setting_set $app ip6_addr none + ynh_app_setting_set $app ip6_net none + ynh_app_setting_set $app login_user "${login_user}" + ynh_app_setting_set $app login_passphrase "${login_passphrase}" + ynh_app_setting_set $app dns0 89.234.141.66 + ynh_app_setting_set $app dns1 2001:913::8 fi @@ -90,20 +129,25 @@ sudo find /var/www/vpnadmin/ -type d -exec chmod +x {} \; sudo mkdir -pm 0770 /etc/openvpn/keys/ sudo chown root:admins /etc/openvpn/keys/ -# Fix confs -## nginx -sudo sed "s||${url_path}|g" -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf" +#================================================= +# NGINX CONFIGURATION +#================================================= + +sudo sed "s||${path_url}|g" -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf" sudo sed 's||/var/www/vpnadmin/|g' -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf" sudo sed 's||vpnadmin|g' -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf" -## php-fpm +#================================================= +# PHP-FPM CONFIGURATION +#================================================= + sudo sed 's||vpnadmin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf sudo sed 's||admin|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf sudo sed 's||admins|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf sudo sed 's||/var/www/vpnadmin/|g' -i /etc/php5/fpm/pool.d/vpnadmin.conf # Fix sources -sudo sed "s||${url_path}|g" -i /var/www/vpnadmin/config.php +sudo sed "s||${path_url}|g" -i /var/www/vpnadmin/config.php # Copy init script sudo install -o root -g root -m 0755 ../conf/ynh-vpnclient /usr/local/bin/ @@ -137,11 +181,11 @@ if ! $upgrade; then ynh_systemctl start ynh-vpnclient # Check configuration consistency - + if [ -z "${crt_server_ca_path}" ]; then echo "WARNING: VPN Client is not started because you need to define a server CA through the web admin" >&2 fi - + if [ -z "${crt_client_key_path}" -a -z "${login_user}" ]; then echo "WARNING: VPN Client is not started because you need either a client certificate, either a username (or both)" >&2 fi diff --git a/scripts/remove b/scripts/remove index 011c908..1ba32f2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,27 +1,40 @@ #!/bin/bash -# VPN Client app for YunoHost +# VPN Client app for YunoHost # Copyright (C) 2015 Julien Vaubourg # Contribute at https://github.com/labriqueinternet/vpnclient_ynh -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. -# +# # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -source ./helpers +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Retrieve arguments -domain=$(sudo yunohost app setting vpnclient domain) +source _common.sh +source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get $app domain) + +#================================================= # The End ynh_systemctl stop ynh-vpnclient-checker.service sudo systemctl disable ynh-vpnclient-checker.service diff --git a/scripts/restore b/scripts/restore index 59f9f4b..aa987d8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,5 +1,24 @@ #!/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" sudo mkdir -p /etc/openvpn/ diff --git a/scripts/upgrade b/scripts/upgrade index 536c496..cf2a1c8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,16 +1,41 @@ #!/bin/bash -ynh_setting() { - app=${1} - setting=${2} - ynh_app_setting_get $app $setting -} +#================================================= +# GENERIC STARTING +#================================================= +# 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 tar czf "/var/cache/labriqueinternet/vpnclient/rollback_$(date +%Y-%m-%d-%H%M%S).tgz" /etc/openvpn/ /etc/yunohost/apps/vpnclient/ &> /dev/null From c4d2bab59cd580f1e1e81550c6c51d68f0c18878 Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Sun, 13 May 2018 11:22:56 +0200 Subject: [PATCH 08/16] doc: Added install badge --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d7d3ebc..a9d3c2a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # VPN Client + [![Build Status](https://travis-ci.org/labriqueinternet/vpnclient_ynh.svg?branch=master)](https://travis-ci.org/labriqueinternet/vpnclient_ynh) +[![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=vpnclient) + ## Overview VPN Client app for [YunoHost](http://yunohost.org/). From 3efa16e19eac9a60c213b5f9e4fb98771e25bc7e Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Sun, 13 May 2018 11:25:37 +0200 Subject: [PATCH 09/16] doc: Update syntax (badges) --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index a9d3c2a..0e66b13 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -# VPN Client +# VPN Client [![Build Status](https://travis-ci.org/labriqueinternet/vpnclient_ynh.svg?branch=master)](https://travis-ci.org/labriqueinternet/vpnclient_ynh) -[![Build Status](https://travis-ci.org/labriqueinternet/vpnclient_ynh.svg?branch=master)](https://travis-ci.org/labriqueinternet/vpnclient_ynh) [![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=vpnclient) ## Overview From 9c736b48046cc304d42a2e2b754b0e756dde779f Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Sun, 13 May 2018 11:37:49 +0200 Subject: [PATCH 10/16] doc: s/NextCloud/LaBriqueInterNet VPNclient/ thx agentcorba --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e66b13..f26bc10 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # VPN Client [![Build Status](https://travis-ci.org/labriqueinternet/vpnclient_ynh.svg?branch=master)](https://travis-ci.org/labriqueinternet/vpnclient_ynh) -[![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=vpnclient) +[![Install LaBriqueInterNet VPNclient with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=vpnclient) ## Overview From a55574ac9bdba7cb6b667247ba8e7c6a2a41e1c4 Mon Sep 17 00:00:00 2001 From: agentcobra Date: Sun, 13 May 2018 11:48:07 +0200 Subject: [PATCH 11/16] Update README.md add integration from jenkins --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f26bc10..45c79cd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# VPN Client [![Build Status](https://travis-ci.org/labriqueinternet/vpnclient_ynh.svg?branch=master)](https://travis-ci.org/labriqueinternet/vpnclient_ynh) - +# VPN Client [![Build Status](https://travis-ci.org/labriqueinternet/vpnclient_ynh.svg?branch=master)](https://travis-ci.org/labriqueinternet/vpnclient_ynh) [![Integration level](https://dash.yunohost.org/integration/vpnclient.svg)](https://ci-apps.yunohost.org/jenkins/job/vpnclient%20%28Community%29/lastBuild/consoleFull) [![Install LaBriqueInterNet VPNclient with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=vpnclient) ## Overview From 24ff5a868769d208fc9fa786e9c15d627a445c74 Mon Sep 17 00:00:00 2001 From: Bastien Date: Sun, 13 May 2018 12:33:59 +0200 Subject: [PATCH 12/16] travis improvement with manifest check JSON --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 867ad1e..b499c28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ -language: php +language: python before_script: - git clone --depth 1 git://github.com/YunoHost/package_linter ../package_linter && cd ../package_linter - mv ../vpnclient_ynh vpnclient_ynh script: + - python -m json.tool vpnclient_ynh/manifest.json - ./package_linter.py vpnclient_ynh notifications: email: false From 081447008c7854ac3a1ae84e4e33eb112572b783 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 22 May 2018 09:43:35 +0200 Subject: [PATCH 13/16] [fix] Let VPN mount (#38) --- conf/ynh-vpnclient | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/ynh-vpnclient b/conf/ynh-vpnclient index 36a97e8..fcea2f8 100644 --- a/conf/ynh-vpnclient +++ b/conf/ynh-vpnclient @@ -129,6 +129,10 @@ start_openvpn() { [ "${ynh_server_proto}" == tcp ] && proto=tcp-client fi + # Unset firewall to let DNS and NTP resolution works + # Firewall is reset after vpn is mounted (more details on #1016) + unset_firewall + sync_time cp /etc/openvpn/client.conf{.tpl,} From 1fc458110660ce775f7613091cde3c5fdcfbe4e6 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Wed, 13 Jun 2018 11:30:43 +0200 Subject: [PATCH 14/16] [fix] Sync the date with http if ntp can't (#37) * [fix] Sync the date with http if ntp can't --- conf/ynh-vpnclient | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/conf/ynh-vpnclient b/conf/ynh-vpnclient index fcea2f8..aad043c 100644 --- a/conf/ynh-vpnclient +++ b/conf/ynh-vpnclient @@ -204,6 +204,20 @@ stop_openvpn() { sync_time() { systemctl stop ntp timeout 20 ntpd -qg &> /dev/null + + # Some networks drop ntp port (udp 123). + # Try to get the date with an http request on the internetcube web site + if [ $? -ne 0 ]; then + http_date=`curl -sD - labriqueinter.net | grep '^Date:' | cut -d' ' -f3-6` + http_date_seconds=`date -d "${http_date}" +%s` + curr_date_seconds=`date +%s` + + # Set the new date if it's greater than the current date + # So it does if 1970 year or if old fake-hwclock date is used + if [ $http_date_seconds -ge $curr_date_seconds ]; then + date -s "${http_date}" + fi + fi systemctl start ntp } From 7800953960334197e8004700218edb084a47c957 Mon Sep 17 00:00:00 2001 From: pitchum Date: Sat, 25 Aug 2018 19:24:31 +0200 Subject: [PATCH 15/16] [fix] upgrade script requires some helpers. ``` Warning: Upgrading app vpnclient... Warning: ./upgrade: line 35: ynh_abort_if_up_to_date: command not found Warning: !! Warning: vpnclient's script has encountered an error. Its execution was cancelled. Warning: !! Warning: Error: Unable to upgrade vpnclient ``` --- scripts/_common.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8c82ee9..5931e78 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -41,3 +41,76 @@ function ynh_systemctl() mv $LOCKFILE.bkp.$$ $LOCKFILE } +# Read the value of a key in a ynh manifest file +# +# usage: ynh_read_manifest manifest key +# | arg: manifest - Path of the manifest to read +# | arg: key - Name of the key to find +ynh_read_manifest () { + manifest="$1" + key="$2" + python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])" +} + +# Read the upstream version from the manifest +# The version number in the manifest is defined by ~ynh +# For example : 4.3-2~ynh3 +# This include the number before ~ynh +# In the last example it return 4.3-2 +# +# usage: ynh_app_upstream_version +ynh_app_upstream_version () { + manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + version_key=$(ynh_read_manifest "$manifest_path" "version") + echo "${version_key/~ynh*/}" +} + +# Read package version from the manifest +# The version number in the manifest is defined by ~ynh +# For example : 4.3-2~ynh3 +# This include the number after ~ynh +# In the last example it return 3 +# +# usage: ynh_app_package_version +ynh_app_package_version () { + manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + version_key=$(ynh_read_manifest "$manifest_path" "version") + echo "${version_key/*~ynh/}" +} + +# Exit without error if the package is up to date +# +# This helper should be used to avoid an upgrade of a package +# when it's not needed. +# +# To force an upgrade, even if the package is up to date, +# you have to set the variable YNH_FORCE_UPGRADE before. +# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp +# +# usage: ynh_abort_if_up_to_date +ynh_abort_if_up_to_date () { + local force_upgrade=${YNH_FORCE_UPGRADE:-0} + local package_check=${PACKAGE_CHECK_EXEC:-0} + + local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0) + local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0) + if [ "$version" = "$last_version" ] + then + if [ "$force_upgrade" != "0" ] + then + echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 + unset YNH_FORCE_UPGRADE + elif [ "$package_check" != "0" ] + then + echo "Upgrade forced for package check." >&2 + else + ynh_die "Up-to-date, nothing to do" 0 + fi + fi +} From aa7bbd6a4cac72a875919bba9d75f84d9e0f2ddd Mon Sep 17 00:00:00 2001 From: pitchum Date: Sun, 26 Aug 2018 17:50:07 +0200 Subject: [PATCH 16/16] [mod] Created file check_process for driving CI builds. --- check_process | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 check_process diff --git a/check_process b/check_process new file mode 100644 index 0000000..1a88c4c --- /dev/null +++ b/check_process @@ -0,0 +1,40 @@ +;; Test complet + ; pre-install + echo -n "Si j'avais des commandes à exécuter ce serait ici " + ; Manifest + domain="domain.tld" (DOMAIN) + path="/vpnconfig" (PATH) + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=0 + setup_nourl=0 + setup_private=1 + setup_public=0 + upgrade=1 + upgrade=1 from_commit=355b24ea0cd3467d7ba1390ab7d34dd4b2500229 + upgrade=1 from_commit=1fc458110660ce775f7613091cde3c5fdcfbe4e6 + backup_restore=1 + multi_instance=0 + incorrect_path=1 + port_already_use=0 + change_url=0 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=0 + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 +;;; Options +Email=pitchum@gramaton.org +Notification=down +#;;; Upgrade options +# ; commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 +# name=Name of this previous version +# manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& +#