Commit 7afd659c authored by HgO's avatar HgO
Browse files

Merge branch 'misc_cleaning' into 'stable'

Misc cleaning to make tests and linter happier on the CI

See merge request !31
parents c5e0d9c0 8545f720
This diff is collapsed.
......@@ -8,19 +8,6 @@ The neutrinet application is for Neutrinet members that have an Internet Cube co
## From the web interface
First make sure you have the neutrinet apps list
1. Go to the admin interface on your cube
2. Click *Tools*
3. In the *Advanced* section, click *Applications lists*
4. Check in the Applications lists section if you have *neutrinet*
If you don't have it, under *Custom applications list*, fill in the form with:
1. Name: *neutrinet*
2. URL: *https://neutrinet.be/apps.json*
Then, click on the *Add* button.
Now, we can install the Neutrinet application:
1. Go to the admin interface
2. Click *Applications*
3. Click *Install* button
......@@ -31,20 +18,6 @@ Now, we can install the Neutrinet application:
## From the CLI
First check if you have a list, probably named *neutrinet*, with *https://neutrinet.be/apps.json* as url.
```shell
yunohost app listlists
```
If you don't have the list yet, you can add it using
```shell
yunohost app fetchlist --name neutrinet -u https://neutrinet.be/apps.json
```
Once you have the list, you can install the app using
```shell
yunohost app install neutrinet --debug
```
......
rewrite ^PATHTOCHANGE$ PATHTOCHANGE/ permanent;
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location PATHTOCHANGE/ {
return 302 PATHTOCHANGE/fr;
location __PATH__/ {
return 302 __PATH__/fr;
}
location PATHTOCHANGE/nl {
alias ALIASTOCHANGE;
rewrite ^__PATH__/nl$ __PATH__/nl/ permanent;
location __PATH__/nl/ {
alias __FINALPATH__/;
index index_nl.html;
}
location PATHTOCHANGE/fr {
alias ALIASTOCHANGE;
rewrite ^__PATH__/fr$ __PATH__/fr/ permanent;
location __PATH__/fr/ {
alias __FINALPATH__/;
index index_fr.html;
}
{
"name": "Neutrinet",
"id": "neutrinet",
"packaging_format": 1,
"description": {
"en": "Auto renewal for the Neutrinet vpn-certificates",
"fr": "Renouvellement automatique des certificats vpn Neutrinet"
},
"version": "0.3.1~ynh1",
"license": "GPL-3+",
"version": "0.3.1~ynh2",
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "ilja",
"email": "neutrinet@spectraltheorem.be",
......@@ -15,7 +16,7 @@
"requirements": {
"yunohost": ">= 3.5.0"
},
"multi_instance": "false",
"multi_instance": false,
"services": [
"nginx"
],
......@@ -31,7 +32,7 @@
"example": "domain.org"
},
{
"name": "path_url",
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Neutrinet application",
......
......@@ -6,8 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
source _common.sh
#=================================================
# MANAGE SCRIPT FAILURE
......@@ -22,9 +22,9 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path_url)
path_url=$(ynh_app_setting_get $app path)
app_user=$(ynh_app_setting_get $app app_user)
www_path=$(ynh_app_setting_get $app www_path)
final_path=$(ynh_app_setting_get $app final_path)
opt_path=$(ynh_app_setting_get $app opt_path)
nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
......@@ -36,7 +36,7 @@ nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
ynh_script_progression "Backing up..."
ynh_backup "$www_path"
ynh_backup "$final_path"
ynh_backup "$nginx_path"
ynh_backup "$opt_path"
......
......@@ -6,8 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
......@@ -19,53 +19,22 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
app=$YNH_APP_INSTANCE_NAME
old_domain=$YNH_APP_OLD_DOMAIN
old_path_url=$YNH_APP_OLD_PATH
www_path=$(ynh_app_setting_get $app www_path)
old_path=$YNH_APP_OLD_PATH
domain=$YNH_APP_NEW_DOMAIN
path_url=$YNH_APP_NEW_PATH
nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
#==================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#==================================================
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Trim trailing slashes
path_url=$(sed 's@*/$@@' <<< $path_url)
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STORE SETTINGS
#=================================================
final_path=$(ynh_app_setting_get $app final_path)
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path_url $path_url
domain=$YNH_APP_NEW_DOMAIN
path_url=$YNH_APP_NEW_PATH
#=================================================
# CHANGE URL IN NGINX CONFIG
#=================================================
ynh_script_progression "Updating nginx configuration..."
cp ../conf/nginx.conf "$nginx_path"
if [[ $path_url == "/" ]]; then
sed -i "/^rewrite/d" "$nginx_path"
path_url=""
fi
sed -i "s@PATHTOCHANGE@$path_url@g" "$nginx_path"
sed -i "s@ALIASTOCHANGE@$www_path@g" "$nginx_path"
if [[ $old_domain != $domain ]]; then
rm -f /etc/nginx/conf.d/$old_domain.d/$app.conf
fi
ynh_script_progression "Reloading nginx web server..."
nginx -tq
ynh_systemd_action nginx reload
ynh_add_nginx_config
......@@ -6,8 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
......@@ -20,37 +20,19 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH_URL
path_url=$YNH_APP_ARG_PATH
app=$YNH_APP_INSTANCE_NAME
app_user=$app
nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
#==================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#==================================================
www_path=/var/www/$app
if [[ -e $www_path ]]
then
ynh_die "The path $www_path already contains a folder"
fi
final_path=/var/www/$app
[[ ! -e $final_path ]] || ynh_die "The path $final_path already contains a folder"
opt_path=/opt/$app
if [[ -e $opt_path ]]
then
ynh_die "The path $opt_path already contains a folder"
fi
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Trim trailing slashes
path_url=$(sed 's@*/$@@' <<< $path_url)
# Check web path availability
if ! ynh_webpath_available $domain $path_url
then
ynh_die "$domain$path_url is not available"
fi
[[ ! -e $opt_path ]] || ynh_die "The path $opt_path already contains a folder"
# Register (book) web path
ynh_webpath_register $app $domain $path_url
......@@ -60,9 +42,9 @@ ynh_webpath_register $app $domain $path_url
#=================================================
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path_url $path_url
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app app_user $app_user
ynh_app_setting_set $app www_path $www_path
ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set $app opt_path $opt_path
#=================================================
......@@ -81,8 +63,8 @@ ynh_install_app_dependencies git python3-openssl python3-requests
ynh_script_progression "Creating app's user…"
mkdir -p $www_path
ynh_system_user_create $app_user $www_path
mkdir -p $final_path
ynh_system_user_create $app_user $final_path
#=================================================
# INSTALL STATIC FILE
......@@ -90,21 +72,10 @@ ynh_system_user_create $app_user $www_path
ynh_script_progression "Installing static site…"
cp -a ../sources/. $www_path
chown -R $app_user: $www_path
cp ../conf/nginx.conf "$nginx_path"
if [[ $path_url == "/" ]]; then
sed -i "/^rewrite/d" "$nginx_path"
path_url=""
fi
sed -i "s@PATHTOCHANGE@$path_url@g" "$nginx_path"
sed -i "s@ALIASTOCHANGE@$www_path@g" "$nginx_path"
cp -a ../sources/. $final_path
chown -R $app_user: $final_path
nginx -tq
ynh_systemd_action nginx reload
ynh_add_nginx_config
#=================================================
# INSTALL RENEW CERT
......@@ -151,4 +122,8 @@ chmod 0755 /etc/cron.daily/$app-renew-cert
ynh_script_progression "Checking certificates…"
/etc/cron.daily/$app-renew-cert
# (This is expected to fail during CI tests because no credential available)
if [[ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]]
then
/etc/cron.daily/$app-renew-cert
fi
......@@ -6,8 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
......@@ -16,11 +16,9 @@ source _common.sh
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path_url)
app_user=$(ynh_app_setting_get $app app_user)
www_path=$(ynh_app_setting_get $app www_path)
final_path=$(ynh_app_setting_get $app final_path)
opt_path=$(ynh_app_setting_get $app opt_path)
nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
#=================================================
# STANDARD REMOVE
......@@ -28,16 +26,14 @@ nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
ynh_script_progression "Removing static site..."
rm -rf $www_path
rm -f "$nginx_path"
ynh_secure_remove $final_path
nginx -tq
ynh_systemd_action nginx reload
ynh_remove_nginx_config
ynh_script_progression "Removing automatic vpn certificate renewal..."
rm -rf $opt_path
rm -rf /etc/cron.daily/$app-renew-cert
ynh_secure_remove $opt_path
ynh_secure_remove /etc/cron.daily/$app-renew-cert
#=================================================
# REMOVE DEPENDENCIES
......
......@@ -6,8 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
source _common.sh
#=================================================
# MANAGE SCRIPT FAILURE
......@@ -22,9 +22,9 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path_url)
path_url=$(ynh_app_setting_get $app path)
app_user=$(ynh_app_setting_get $app app_user)
www_path=$(ynh_app_setting_get $app www_path)
final_path=$(ynh_app_setting_get $app final_path)
opt_path=$(ynh_app_setting_get $app opt_path)
nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
......@@ -34,15 +34,9 @@ nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
ynh_script_progression "Checking for conflicts…"
[[ ! -e $www_path ]] || ynh_die "The path $www_path already contains a folder"
[[ ! -e $final_path ]] || ynh_die "The path $final_path already contains a folder"
[[ ! -e $opt_path ]] || ynh_die "The path $opt_path already contains a folder"
# Check web path availability
if ! ynh_webpath_available "$domain" "$path_url"
then
ynh_die "$domain$path_url is no longer available"
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
......@@ -57,8 +51,8 @@ ynh_install_app_dependencies git python3-openssl python3-requests
# CREATE DEDICATED USER
#=================================================
mkdir -p "$www_path"
ynh_system_user_create $app_user "$www_path"
mkdir -p "$final_path"
ynh_system_user_create $app_user "$final_path"
#=================================================
# RESTORE STATIC FILES
......@@ -66,9 +60,9 @@ ynh_system_user_create $app_user "$www_path"
ynh_script_progression "Restoring static site…"
ynh_restore_file "$www_path"
ynh_restore_file "$final_path"
ynh_restore_file "$nginx_path"
chown -R $app_user: "$www_path"
chown -R $app_user: "$final_path"
nginx -tq
ynh_systemd_action nginx reload
......@@ -94,5 +88,8 @@ chmod 0755 /etc/cron.daily/$app-renew-cert \
ynh_script_progression "Checking certificates…"
/etc/cron.daily/$app-renew-cert
# (This is expected to fail during CI tests because no credential available)
if [[ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]]
then
/etc/cron.daily/$app-renew-cert
fi
......@@ -6,8 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
......@@ -16,10 +16,9 @@ source _common.sh
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path)
path_url=$(ynh_app_setting_get $app path_url)
path_url=$(ynh_app_setting_get $app path)
app_user=$(ynh_app_setting_get $app app_user)
www_path=$(ynh_app_setting_get $app www_path)
final_path=$(ynh_app_setting_get $app final_path)
opt_path=$(ynh_app_setting_get $app opt_path)
# There are two ways to get the version:
......@@ -30,17 +29,35 @@ opt_path=$(ynh_app_setting_get $app opt_path)
manifest=/etc/yunohost/apps/$app/manifest.json
version=$(jq '.version // empty' -r -e $manifest || ynh_app_setting_get $app version)
nginx_path=/etc/nginx/conf.d/$domain.d/$app.conf
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression "Creating backup..."
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
if [[ -z $www_path ]]; then
www_path=/var/www/$app
ynh_app_setting_set $app www_path $www_path
if [[ -z $final_path ]]; then
if [[ -n "$(ynh_app_setting_get $app www_path)" ]]; then
final_path=$(ynh_app_setting_get $app www_path)
ynh_app_setting_delete $app www_path
else
final_path=/var/www/$app
fi
ynh_app_setting_set $app final_path $final_path
mkdir -p $www_path
mkdir -p $final_path
fi
if [[ -z $opt_path ]]; then
......@@ -55,41 +72,6 @@ if [[ -z $app_user ]]; then
ynh_app_setting_set $app app_user $app_user
fi
# Trim trailing slashes
path_url=$(sed 's@/*$@@' <<< $path_url)
if [[ -z $path_url ]]; then
path_url=$path
if [[ -z $path_url ]]; then
ynh_die "Missing path url!"
else
ynh_app_setting_set $app path_url $path_url
fi
fi
# path setting is needed by Yunohost
# when path is empty, Yunohost thinks the app is on the domain root
if [[ "$path" != "$path_url" ]]; then
path=$path_url
ynh_app_setting_set $app path $path
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression "Creating backup..."
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
......@@ -100,7 +82,7 @@ ynh_script_progression "Upgrading dependencies..."
if [[ $version < "0.3.0~ynh1" ]]; then
ynh_app_setting_delete $app version
ynh_system_user_create --username $app_user --home_dir $www_path
ynh_system_user_create --username $app_user --home_dir $final_path
fi
if [[ $version < "0.3.0~ynh4" ]]; then
......@@ -119,23 +101,12 @@ fi
ynh_script_progression "Installing static site..."
rm -rf $www_path
mkdir -p $www_path
cp -r ../sources/. $www_path
chown -R $app_user: $www_path
ynh_secure_remove $final_path
mkdir -p $final_path
cp -r ../sources/. $final_path
chown -R $app_user: $final_path
cp ../conf/nginx.conf "$nginx_path"
if [[ $path_url == "/" ]]; then
sed -i "/^rewrite/d" "$nginx_path"
path_url=""
fi
sed -i "s@PATHTOCHANGE@$path_url@g" "$nginx_path"
sed -i "s@ALIASTOCHANGE@$www_path@g" "$nginx_path"
nginx -tq
ynh_systemd_action nginx reload
ynh_add_nginx_config
#=================================================
# REINSTALL RENEW CERT
......@@ -187,4 +158,9 @@ chmod 0755 /etc/cron.daily/$app-renew-cert
#=================================================
ynh_script_progression "Checking certificates..."
/etc/cron.daily/$app-renew-cert
# (This is expected to fail during CI tests because no credential available)
if [[ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]]
then
/etc/cron.daily/$app-renew-cert
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment