Browse Source

Packaging v2

Alexandre Aubin 1 year ago
parent
commit
6d9e34489a
16 changed files with 71 additions and 285 deletions
  1. 0 16
      check_process
  2. 1 1
      doc/DESCRIPTION.md
  3. 1 1
      doc/DESCRIPTION_fr.md
  4. 0 1
      doc/DISCLAIMER.md
  5. 0 1
      doc/DISCLAIMER_fr.md
  6. 8 0
      doc/PRE_INSTALL.md
  7. 7 0
      doc/PRE_INSTALL_fr.md
  8. 0 43
      manifest.json
  9. 37 0
      manifest.toml
  10. 0 10
      scripts/_common.sh
  11. 0 24
      scripts/backup
  12. 0 51
      scripts/install
  13. 0 45
      scripts/remove
  14. 0 42
      scripts/restore
  15. 10 50
      scripts/upgrade
  16. 7 0
      tests.toml

+ 0 - 16
check_process

@@ -1,16 +0,0 @@
-;; Test complet
-    ; Manifest
-    ; Checks
-        pkg_linter=1
-        setup_sub_dir=0
-        setup_root=0
-        setup_nourl=1
-        setup_private=0
-        setup_public=0
-        upgrade=1
-        upgrade=1   from_commit=0d2a6b1d9a71f63dedfc2b05b35c93c73a130886
-        backup_restore=1
-        multi_instance=0
-        incorrect_path=0
-        port_already_use=0
-        change_url=0

+ 1 - 1
doc/DESCRIPTION.md

@@ -1,4 +1,4 @@
-* Install a VPN connection on your self-hosted server.
+Install a VPN connection on your self-hosted server.
 * Useful for hosting your server behind a filtered (and/or non-neutral) internet access.
 * Useful to have static IP addresses (IPv6 and IPv4).
 * Useful to easily move your server anywhere.

+ 1 - 1
doc/DESCRIPTION_fr.md

@@ -1,4 +1,4 @@
-* Installez une connexion VPN sur votre serveur auto-hébergé
+Installez une connexion VPN sur votre serveur auto-hébergé
 * Utile pour héberger votre serveur derrière un accès internet filtré (et/ou non-neutre)
 * Utile pour obtenir une IP statique (v4 et v6)
 * Utile pour pouvoir facilement déplacer votre serveur

+ 0 - 1
doc/DISCLAIMER.md

@@ -1 +0,0 @@
-Please note that this application is designed to interface with **dedicated, public IP VPNs accepting inbound traffic**, preferably with an associated `.cube` (or `.ovpn/.conf`) configuration file. **Do not** expect that any VPN you randomly bought on the Internet can be used! Checkout the [list of known compatible providers](https://yunohost.org/providers/vpn) for more info.

+ 0 - 1
doc/DISCLAIMER_fr.md

@@ -1 +0,0 @@
-Notez que cette application est prévue pour fonctionner avec des **VPN dédiés et à IP publique qui acceptent le traffic entrant**, et de préférence avec un fichier de configuration `.cube` (ou `.ovpn/.conf`) associé. Un VPN acheté au hasard sur Internet ne fonctionnera sans doute pas ! Consultez [la liste des fournisseurs connus et compatibles](https://yunohost.org/providers/vpn) pour plus d'infos.

+ 8 - 0
doc/PRE_INSTALL.md

@@ -0,0 +1,8 @@
+Please note that this application only interfaces with **dedicated, public IP VPNs accepting inbound traffic**, 
+preferably with an associated `.cube` (or `.ovpn/.conf`) configuration file.
+
+**Do not** expect that any VPN you randomly bought on the Internet can be used! 
+
+Checkout the [list of known compatible providers](https://yunohost.org/providers/vpn) for more info.
+    
+After installation, you will be able to configure the application from YunoHost's webadmin in Applications > VPNclient > Configuration

+ 7 - 0
doc/PRE_INSTALL_fr.md

@@ -0,0 +1,7 @@
+Notez que cette application est prévue pour fonctionner avec des **VPN dédiés et à IP publique qui acceptent le traffic entrant**, et de préférence avec un fichier de configuration `.cube` (ou `.ovpn/.conf`) associé. 
+
+Un VPN acheté au hasard sur Internet ne fonctionnera sans doute pas ! 
+
+Consultez [la liste des fournisseurs connus et compatibles](https://yunohost.org/providers/vpn) pour plus d'infos.
+
+Après l'application, vous pourrez configurer l'application depuis la webadmin de YunoHost dans Applications > VPNclient > Configuration.

+ 0 - 43
manifest.json

@@ -1,43 +0,0 @@
-{
-  "name": "VPN Client",
-  "id": "vpnclient",
-  "packaging_format": 1,
-  "description": {
-    "en": "Tunnel the internet traffic through a VPN",
-    "fr": "Fait passer le trafic internet à travers un VPN"
-  },
-  "version": "2.2~ynh1",
-  "url": "https://labriqueinter.net",
-  "license": "AGPL-3.0",
-  "maintainer": {
-    "name": "pitchum",
-    "email": "pitchum@users.noreply.github.com"
-  },
-  "multi_instance": false,
-  "requirements": {
-    "yunohost": ">= 4.3.2"
-  },
-  "services": [],
-  "arguments": {
-      "install": [
-          {
-            "name": "disclaimer1",
-            "type": "display_text",
-            "style": "warning",
-            "ask": {
-                "en": "Please note that this application only interfaces with **dedicated, public IP VPNs accepting inbound traffic**, preferably with an associated `.cube` (or `.ovpn/.conf`) configuration file. **Do not** expect that any VPN you randomly bought on the Internet can be used! Checkout the [list of known compatible providers](https://yunohost.org/providers/vpn) for more info.",
-                "fr": "Notez que cette application est prévue pour fonctionner avec des **VPN dédiés et à IP publique qui acceptent le traffic entrant**, et de préférence avec un fichier de configuration `.cube` (ou `.ovpn/.conf`) associé. Un VPN acheté au hasard sur Internet ne fonctionnera sans doute pas ! Consultez [la liste des fournisseurs connus et compatibles](https://yunohost.org/providers/vpn) pour plus d'infos."
-            }
-        },
-        {
-            "name": "disclaimer2",
-            "type": "display_text",
-            "style": "info",
-            "ask": {
-                "en": "After installation, you will be able to configure the application from YunoHost's webadmin in Applications > VPNclient > Configuration.",
-                "fr": "Après l'application, vous pourrez configurer l'application depuis la webadmin de YunoHost dans Applications > VPNclient > Configuration."
-            }
-        }
-    ]
-  }
-}

+ 37 - 0
manifest.toml

@@ -0,0 +1,37 @@
+#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
+
+packaging_format = 2
+
+id = "vpnclient"
+name = "VPN Client"
+description.en = "Tunnel the internet traffic through a VPN"
+description.fr = "Fait passer le trafic internet à travers un VPN"
+
+version = "2.2~ynh1"
+
+maintainers = []
+
+[upstream]
+license = "AGPL-3.0"
+website = "https://labriqueinter.net"
+
+[integration]
+yunohost = ">= 4.3.2"
+architectures = "all"
+multi_instance = false
+ldap = "not_relevant"
+sso = "not_relevant"
+disk = "50M"
+ram.build = "50M"
+ram.runtime = "50M"
+
+[install]
+
+
+[resources]
+    [resources.system_user]
+
+    [resources.permissions]
+
+    [resources.apt]
+    packages = "sipcalc, dnsutils, openvpn, curl, fake-hwclock"

+ 0 - 10
scripts/_common.sh

@@ -1,9 +1,4 @@
 #!/bin/bash
-#
-# Common variables and helpers
-#
-
-pkg_dependencies="sipcalc dnsutils openvpn curl fake-hwclock"
 
 service_name="ynh-vpnclient"
 service_checker_name=$service_name"-checker"
@@ -12,11 +7,6 @@ service_checker_name=$service_name"-checker"
 # Operations needed by both 'install' and 'upgrade' scripts
 function vpnclient_deploy_files_and_services()
 {
-  # Ensure vpnclient_ynh has its own system user
-  if ! ynh_system_user_exists ${app}
-  then
-    ynh_system_user_create ${app}
-  fi
 
   # Install command-line cube file loader
   install -o root -g root -m 0755 ../conf/$service_name-loadcubefile.sh /usr/local/bin/

+ 0 - 24
scripts/backup

@@ -1,31 +1,9 @@
 #!/bin/bash
 
-#=================================================
-# GENERIC START
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
 source ../settings/scripts/_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
-#=================================================
-ynh_print_info "Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
-# STANDARD BACKUP STEPS
-#=================================================
 # BACKUP THE APP MAIN DIR
 #=================================================
 ynh_print_info "Backing up the main app directory..."
@@ -55,8 +33,6 @@ ynh_backup --src_path="/usr/local/bin/$service_name"
 ynh_backup --src_path="/usr/local/bin/$service_checker_name.sh"
 
 #=================================================
-# SPECIFIC BACKUP
-#=================================================
 # BACKUP SYSTEMD
 #=================================================
 ynh_print_info "Backing up systemd configuration..."

+ 0 - 51
scripts/install

@@ -1,50 +1,8 @@
 #!/bin/bash
 
-# VPN Client app for YunoHost
-# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
-# 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 <http://www.gnu.org/licenses/>.
-
-#=================================================
-# 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
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
-# STORE SETTINGS FROM MANIFEST
-#=================================================
-ynh_script_progression "Storing installation settings..."
-
 # Default values for config panel
 ynh_app_setting_set "$app" service_enabled 0
 ynh_app_setting_set "$app" dns_method "yunohost"
@@ -53,15 +11,6 @@ ynh_app_setting_set "$app" ip6_addr ""
 ynh_app_setting_set "$app" ip6_net ""
 
 #=================================================
-# STANDARD MODIFICATIONS
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression "Installing dependencies..."
-
-ynh_install_app_dependencies "$pkg_dependencies"
-
-#=================================================
 # DEPLOY FILES FROM PACKAGE
 #=================================================
 ynh_script_progression "Deploy files from package..."

+ 0 - 45
scripts/remove

@@ -1,39 +1,9 @@
 #!/bin/bash
 
-# VPN Client app for YunoHost
-# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
-# 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 <http://www.gnu.org/licenses/>.
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
 source _common.sh
 source /usr/share/yunohost/helpers
 
 #=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_print_info "Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
 # STOP AND REMOVE SERVICES
 #=================================================
 ynh_print_info "Stopping and removing services"
@@ -95,21 +65,6 @@ ynh_print_info "Reloading firewall"
 yunohost firewall reload
 
 #=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-ynh_print_info "Removing dependencies"
-ynh_remove_app_dependencies
-
-#=================================================
-# REMOVE DEDICATED USER
-#=================================================
-
-ynh_print_info "Removing the dedicated system user"
-
-# Delete a system user
-ynh_system_user_delete ${app}
-
-#=================================================
 # END OF SCRIPT
 #=================================================
 

+ 0 - 42
scripts/restore

@@ -1,29 +1,9 @@
 #!/bin/bash
 
-#=================================================
-# GENERIC START
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
 source ../settings/scripts/_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
-#=================================================
-ynh_print_info "Loading settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
 # RESTORE THE APP MAIN DIR
 #=================================================
 ynh_print_info "Restoring the app files..."
@@ -53,24 +33,6 @@ ynh_restore_file --origin_path="/usr/local/bin/$service_name"
 ynh_restore_file --origin_path="/usr/local/bin/$service_checker_name.sh"
 
 #=================================================
-# RECREATE THE DEDICATED USER
-#=================================================
-ynh_print_info "Recreating the dedicated system user..."
-
-# Create the dedicated user (if not existing)
-ynh_system_user_create $app
-
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_print_info "Reinstalling dependencies..."
-
-# Define and install dependencies
-ynh_install_app_dependencies "$pkg_dependencies"
-
-#=================================================
 # RESTORE SYSTEMD
 #=================================================
 ynh_print_info "Restoring the systemd configuration..."
@@ -91,10 +53,6 @@ systemctl enable "openvpn@.service" --quiet
 yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
 
 #=================================================
-# GENERIC FINALIZATION
-#=================================================
-
-#=================================================
 # END OF SCRIPT
 #=================================================
 

+ 10 - 50
scripts/upgrade

@@ -1,31 +1,10 @@
 #!/bin/bash
 
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
 source _common.sh
 source /usr/share/yunohost/helpers
 
-ynh_abort_if_errors
-
-#=================================================
-# LOAD SETTINGS
 #=================================================
-ynh_print_info "Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-dns_method=$(ynh_app_setting_get $app dns_method)
-nameservers=$(ynh_app_setting_get $app nameservers)
-service_enabled=$(ynh_app_setting_get $app service_enabled)
-ip6_addr=$(ynh_app_setting_get $app ip6_addr)
-ip6_net=$(ynh_app_setting_get $app ip6_net)
-
-#=================================================
-# SPECIAL UPGRADE FOR VERSIONS < 1.2.0
+# SPECIAL UPGRADE FOR VERSIONS < 2.0
 #=================================================
 
 # Removing configuration files with naming that occured in versions < 1.2.0 ("vpnadmin" instead off "$app")
@@ -33,10 +12,6 @@ if [ -d /var/www/vpnadmin ]; then
   ynh_secure_remove /var/www/vpnadmin
 fi
 
-#=================================================
-# SPECIAL UPGRADE FOR VERSIONS < 2.0
-#=================================================
-
 # Old stuff
 
 if [ -f /etc/nginx/conf.d/*.d/$app.conf ]; then
@@ -52,10 +27,10 @@ if [ -d /var/www/$app ]; then
 	ynh_secure_remove /var/www/$app
 fi
 
-[ -z "$(ynh_app_setting_get $app domain)" ] || ynh_app_setting_delete $app domain
-[ -z "$(ynh_app_setting_get $app path)" ] || ynh_app_setting_delete $app path
-[ -z "$(ynh_app_setting_get $app is_public)" ] || ynh_app_setting_delete $app is_public
-[ -z "$(ynh_app_setting_get $app final_path)" ] || ynh_app_setting_delete $app final_path
+[ -z "${domain:-}" ] || ynh_app_setting_delete $app domain
+[ -z "${path:-}" ] || ynh_app_setting_delete $app path
+[ -z "${is_public:-}" ] || ynh_app_setting_delete $app is_public
+[ -z "${install_dir:-}" ] || ynh_app_setting_delete $app install_dir
 
 if [ -e "/etc/sudoers.d/${app}_ynh" ]; then
   ynh_secure_remove "/etc/sudoers.d/${app}_ynh"
@@ -63,20 +38,20 @@ fi
 
 # New stuff
 
-if [ -z "$dns_method" ]; then
+if [ -z "${dns_method:-}" ]; then
     ynh_app_setting_set --app=$app --key=dns_method --value=custom
 fi
-if [ -z "$nameservers" ]; then
+if [ -z "${nameservers:-}" ]; then
     nameservers="$(grep -o -P '\s*nameserver\s+\K[abcdefabcdef\d.:]+' /etc/resolv.dnsmasq.conf | sort | uniq | paste -s -d, -)"
     ynh_app_setting_set --app=$app --key=nameservers --value="$nameservers"
 fi
-if [ -z "$service_enabled" ]; then
+if [ -z "${service_enabled:-}" ]; then
     ynh_app_setting_set --app=$app --key=service_enabled --value=0
 fi
-if [ -z "$ip6_addr" ]; then
+if [ -z "${ip6_addr:-}" ]; then
     ynh_app_setting_set --app=$app --key=ip6_addr --value=""
 fi
-if [ -z "$ip6_net" ]; then
+if [ -z "${ip6_net:-}" ]; then
     ynh_app_setting_set --app=$app --key=ip6_net --value=""
 fi
 
@@ -88,21 +63,6 @@ if [ -e "/etc/systemd/system/openvpn@.service" ]; then
   ynh_secure_remove "/etc/systemd/system/openvpn@.service"
 fi
 
-##=================================================
-## BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
-##=================================================
-
-# Not done because vpnclient backup ain't so relevant I guess ?
-
-#=================================================
-# DO UPGRADE
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-ynh_print_info "Installing dependencies..."
-
-ynh_install_app_dependencies "$pkg_dependencies"
-
 #=================================================
 # DEPLOY FILES FROM PACKAGE
 #=================================================

+ 7 - 0
tests.toml

@@ -0,0 +1,7 @@
+#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
+
+test_format = 1.0
+
+[default]
+
+    [default.test_upgrade_from.0d2a6b1d]