mirror of
https://github.com/YunoHost-Apps/outline_ynh.git
synced 2024-09-03 19:56:12 +02:00
commit
7dc000bdf5
10 changed files with 197 additions and 146 deletions
|
@ -1,14 +1,16 @@
|
|||
;; Test complet
|
||||
; pre-install
|
||||
sudo yunohost domain add dex.domain.tld
|
||||
sudo yunohost domain add minio.domain.tld
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/"
|
||||
language="fr"
|
||||
is_public=1
|
||||
password="1Strong-Password"
|
||||
port="666"
|
||||
slack_key="slack"
|
||||
slack_secret="secret"
|
||||
minio_domain="sub.domain.tld"
|
||||
language="fr"
|
||||
dex_domain="dex.domain.tld"
|
||||
dex_path="/example"
|
||||
minio_domain="minio.domain.tld"
|
||||
minio_admin="package_checker"
|
||||
minio_password="1Strong-Password"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -16,7 +18,7 @@
|
|||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=0
|
||||
upgrade=1
|
||||
#upgrade=1 from_commit=CommitHash
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
|
|
|
@ -77,9 +77,9 @@ AZURE_RESOURCE_APP_ID=
|
|||
# Redirect URI is https://<URL>/auth/oidc.callback
|
||||
OIDC_CLIENT_ID=__OIDC_NAME__
|
||||
OIDC_CLIENT_SECRET=__OIDC_SECRET__
|
||||
OIDC_AUTH_URI=https://__DEX_DOMAIN____DEX_PATH__auth
|
||||
OIDC_TOKEN_URI=https://__DEX_DOMAIN____DEX_PATH__token
|
||||
OIDC_USERINFO_URI=https://__DEX_DOMAIN____DEX_PATH__userinfo
|
||||
OIDC_AUTH_URI=__DEX_AUTH_URI__
|
||||
OIDC_TOKEN_URI=__DEX_TOKEN_URI__
|
||||
OIDC_USERINFO_URI=__DEX_USER_URI__
|
||||
|
||||
# Specify which claims to derive user information from
|
||||
# Supports any valid JSON path with the JWT payload
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
location / {
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
proxy_pass http://127.0.0.1:__PORT__;
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
|
|
|
@ -31,9 +31,7 @@
|
|||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "wiki.domain.tld",
|
||||
"ask": "Domain for Outline app. This will be the main domain to access the wiki. Outline has to be installed at the root"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
|
@ -53,19 +51,17 @@
|
|||
{
|
||||
"name": "dex_domain",
|
||||
"type": "domain",
|
||||
"example": "auth.domain.tld",
|
||||
"ask": "Domain for authentification. It can't be the same domain as above. Dex app will be installed and used for the authentification mechanism"
|
||||
},
|
||||
{
|
||||
"name": "dex_path",
|
||||
"type": "path",
|
||||
"example": "/example",
|
||||
"default": "/example"
|
||||
"default": "/",
|
||||
"ask": "Path for authentification url. Please don't use 'auth' as it will break Nginx configuration"
|
||||
},
|
||||
{
|
||||
"name": "minio_domain",
|
||||
"type": "domain",
|
||||
"example": "docs.domain.tld",
|
||||
"ask": "Domain for MinIO app, used for images and attachements storage. If not yet installed, it will automatically be. Minio has to be installed at the root"
|
||||
},
|
||||
{
|
||||
|
@ -76,7 +72,6 @@
|
|||
{
|
||||
"name": "minio_password",
|
||||
"type": "password",
|
||||
"example": "docs.domain.tld",
|
||||
"ask": "Domain for MinIO app, used for images and attachements storage. Please note that if MinIO is already installed, that setting won't be used"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -36,16 +36,19 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|||
language_key=$(ynh_app_setting_get --app=$app --key=language_key)
|
||||
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
|
||||
utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret)
|
||||
minio_domain=$(ynh_app_setting_get --app="minio" --key=domain)
|
||||
minio_admin=$(ynh_app_setting_get --app="minio" --key=admin)
|
||||
minio_password=$(ynh_app_setting_get --app="minio" --key=password)
|
||||
minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key)
|
||||
mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path)
|
||||
dex_domain=$(ynh_app_setting_get --app="minio" --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app="minio" --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app="minio" --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app="minio" --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app="minio" --key=oidc_callback)
|
||||
minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain)
|
||||
minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin)
|
||||
minio_password=$(ynh_app_setting_get --app=$app --key=minio_password)
|
||||
mc_path=$(ynh_app_setting_get --app=$app --key=mc_path)
|
||||
dex_app=$(ynh_app_setting_get --app=$app --key=dex_app)
|
||||
dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app=$app --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback)
|
||||
dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri)
|
||||
dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri)
|
||||
dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
|
|
@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
@ -35,21 +35,24 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|||
language_key=$(ynh_app_setting_get --app=$app --key=language_key)
|
||||
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
|
||||
utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret)
|
||||
minio_domain=$(ynh_app_setting_get --app="minio" --key=domain)
|
||||
minio_admin=$(ynh_app_setting_get --app="minio" --key=admin)
|
||||
minio_password=$(ynh_app_setting_get --app="minio" --key=password)
|
||||
minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key)
|
||||
mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path)
|
||||
dex_domain=$(ynh_app_setting_get --app="minio" --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app="minio" --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app="minio" --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app="minio" --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app="minio" --key=oidc_callback)
|
||||
minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain)
|
||||
minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin)
|
||||
minio_password=$(ynh_app_setting_get --app=$app --key=minio_password)
|
||||
mc_path=$(ynh_app_setting_get --app=$app --key=mc_path)
|
||||
dex_app=$(ynh_app_setting_get --app=$app --key=dex_app)
|
||||
dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app=$app --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback)
|
||||
dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri)
|
||||
dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri)
|
||||
dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -84,14 +87,14 @@ fi
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
|
@ -112,7 +115,7 @@ fi
|
|||
domain=$new_domain
|
||||
|
||||
ynh_secure_remove --file="$final_path/.env"
|
||||
ynh_script_progression --message="Updating the configuration file..." --time --weight=1
|
||||
ynh_script_progression --message="Updating the configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
|
||||
|
||||
|
@ -134,14 +137,14 @@ popd
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -155,4 +158,4 @@ ynh_print_info --message="Don't forget to add a new redirction url in your Slack
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
|
|
|
@ -60,7 +60,6 @@ fi
|
|||
minio_domain=$(ynh_app_setting_get --app="minio" --key=domain)
|
||||
minio_admin=$(ynh_app_setting_get --app="minio" --key=admin)
|
||||
minio_password=$(ynh_app_setting_get --app="minio" --key=password)
|
||||
minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key)
|
||||
mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path)
|
||||
|
||||
#=================================================
|
||||
|
@ -74,18 +73,32 @@ oidc_secret=$(ynh_hex_32_random)
|
|||
oidc_name="Outline"
|
||||
oidc_callback="$domain/auth/oidc.callback"
|
||||
|
||||
if yunohost app list | grep -q "$YNH_APP_ARG_DEX_DOMAIN"; then
|
||||
if yunohost app list | grep -q "$YNH_APP_ARG_DEX_DOMAIN$YNH_APP_ARG_DEX_PATH"; then
|
||||
ynh_die "The domain provided for Dex is already used by another app. Please chose another one !"
|
||||
fi
|
||||
|
||||
yunohost app install https://github.com/YunoHost-Apps/dex_ynh --force --args "domain=$dex_domain&path=$dex_path&OIDC_name=$oidc_name&OIDC_secret=$oidc_secret&OIDC_callback=$oidc_callback"
|
||||
yunohost app install https://github.com/YunoHost-Apps/dex_ynh --force --args "domain=$dex_domain&path=$dex_path&OIDC_name=$oidc_name&OIDC_secret=$oidc_secret&OIDC_callback=$oidc_callback" 2>&1 | tee dexlog.txt
|
||||
dex_app=$(gawk 'match($0, /Installation of (.+) completed/, app) {print app[1]}' dexlog.txt)
|
||||
rm dexlog.txt
|
||||
|
||||
# Create Dex URIs
|
||||
if [ $dex_path = "/" ]
|
||||
then
|
||||
dex_auth_uri="https://$dex_domain/auth"
|
||||
dex_token_uri="https://$dex_domain/token"
|
||||
dex_user_uri="https://$dex_domain/userinfo"
|
||||
else
|
||||
dex_auth_uri="https://$dex_domain$dex_path/auth"
|
||||
dex_token_uri="https://$dex_domain$dex_path/token"
|
||||
dex_user_uri="https://$dex_domain$dex_path/userinfo"
|
||||
fi
|
||||
|
||||
#===================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#===================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
final_path=/opt/yunohost/$app
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
|
@ -102,11 +115,19 @@ ynh_app_setting_set --app=$app --key=language --value=$language
|
|||
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
|
||||
ynh_app_setting_set --app=$app --key=utils_secret --value=$utils_secret
|
||||
ynh_app_setting_set --app=$app --key=language_key --value=$language_key
|
||||
ynh_app_setting_set --app=$app --key=minio_domain --value=$minio_domain
|
||||
ynh_app_setting_set --app=$app --key=minio_admin --value=$minio_admin
|
||||
ynh_app_setting_set --app=$app --key=minio_password --value=$minio_password
|
||||
ynh_app_setting_set --app=$app --key=mc_path --value=$mc_path
|
||||
ynh_app_setting_set --app=$app --key=dex_app --value=$dex_app
|
||||
ynh_app_setting_set --app=$app --key=dex_domain --value=$dex_domain
|
||||
ynh_app_setting_set --app=$app --key=dex_path --value=$dex_path
|
||||
ynh_app_setting_set --app=$app --key=oidc_name --value=$oidc_name
|
||||
ynh_app_setting_set --app=$app --key=oidc_secret --value=$oidc_secret
|
||||
ynh_app_setting_set --app=$app --key=oidc_callback --value=$oidc_callback
|
||||
ynh_app_setting_set --app=$app --key=dex_auth_uri --value=$dex_auth_uri
|
||||
ynh_app_setting_set --app=$app --key=dex_token_uri --value=$dex_token_uri
|
||||
ynh_app_setting_set --app=$app --key=dex_user_uri --value=$dex_user_uri
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -125,12 +146,12 @@ ynh_app_setting_set --app=$app --key=port --value=$port
|
|||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||
|
||||
# Install nodejs
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies 2>&1
|
||||
|
||||
# Install Yarn
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" 2>&1
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -228,8 +249,6 @@ popd
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
|
|
|
@ -12,27 +12,31 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path_url)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
language_key=$(ynh_app_setting_get --app=$app --key=language_key)
|
||||
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
|
||||
utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret)
|
||||
minio_domain=$(ynh_app_setting_get --app="minio" --key=domain)
|
||||
minio_admin=$(ynh_app_setting_get --app="minio" --key=admin)
|
||||
minio_password=$(ynh_app_setting_get --app="minio" --key=password)
|
||||
minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key)
|
||||
mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path)
|
||||
dex_domain=$(ynh_app_setting_get --app="minio" --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app="minio" --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app="minio" --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app="minio" --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app="minio" --key=oidc_callback)
|
||||
minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain)
|
||||
minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin)
|
||||
minio_password=$(ynh_app_setting_get --app=$app --key=minio_password)
|
||||
mc_path=$(ynh_app_setting_get --app=$app --key=mc_path)
|
||||
dex_app=$(ynh_app_setting_get --app=$app --key=dex_app)
|
||||
dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app=$app --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback)
|
||||
dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri)
|
||||
dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri)
|
||||
dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -43,14 +47,14 @@ oidc_callback=$(ynh_app_setting_get --app="minio" --key=oidc_callback)
|
|||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
@ -58,7 +62,7 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
@ -74,7 +78,7 @@ ynh_psql_remove_db --db_user=$db_name --db_name=$db_name
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -83,15 +87,22 @@ ynh_remove_nodejs
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEX APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing Dex app used for Outline auth..." --weight=1
|
||||
|
||||
yunohost app remove $dex_app
|
||||
|
||||
#=================================================
|
||||
# REMOVE MINIO BUCKET
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing Outline MinIO bucket..." --time --weight=1
|
||||
ynh_script_progression --message="Removing Outline MinIO bucket..." --weight=1
|
||||
|
||||
pushd "$mc_path"
|
||||
ynh_exec_warn_less sudo -u minio ./mc rb minio/outlinestorage --force
|
||||
|
@ -100,7 +111,7 @@ popd
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -110,7 +121,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
@ -120,5 +131,4 @@ ynh_system_user_delete --username=$app
|
|||
#=================================================
|
||||
|
||||
ynh_script_progression --message="If you don't need it anymore, don't forget to remove the MinIO app !"
|
||||
ynh_script_progression --message="If you don't need it anymore, don't forget to remove the Dex app !"
|
||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -21,19 +21,10 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK IF MINIO IS INSTALLED, IF NOT WARN USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking if MinIO is installed..." --time --weight=1
|
||||
|
||||
if ! yunohost app list | grep -q "id: minio"; then
|
||||
ynh_die --message="We can't restore because MinIO is not installed ! Please install MinIO first"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -45,38 +36,69 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|||
language_key=$(ynh_app_setting_get --app=$app --key=language_key)
|
||||
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
|
||||
utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret)
|
||||
minio_domain=$(ynh_app_setting_get --app="minio" --key=domain)
|
||||
minio_admin=$(ynh_app_setting_get --app="minio" --key=admin)
|
||||
minio_password=$(ynh_app_setting_get --app="minio" --key=password)
|
||||
minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key)
|
||||
mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path)
|
||||
dex_domain=$(ynh_app_setting_get --app="minio" --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app="minio" --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app="minio" --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app="minio" --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app="minio" --key=oidc_callback)
|
||||
minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain)
|
||||
minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin)
|
||||
minio_password=$(ynh_app_setting_get --app=$app --key=minio_password)
|
||||
mc_path=$(ynh_app_setting_get --app=$app --key=mc_path)
|
||||
dex_app=$(ynh_app_setting_get --app=$app --key=dex_app)
|
||||
dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app=$app --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback)
|
||||
dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri)
|
||||
dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri)
|
||||
dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF DEX IS INSTALLED, IF NOT INSTALL IT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Dex if needed..." --weight=18
|
||||
|
||||
if ! yunohost app list | grep -q "id: $dex_app"; then
|
||||
echo "Dex is not installed. Installing... "
|
||||
yunohost tools update
|
||||
if yunohost app list | grep -q "$dex_domain$dex_path"; then
|
||||
ynh_die "The domain provided for Dex is already used by another app. Please chose another one !"
|
||||
fi
|
||||
yunohost app install https://github.com/YunoHost-Apps/dex_ynh --force --args "domain=$dex_domain&path=$dex_path&OIDC_name=$oidc_name&OIDC_secret=$oidc_secret&OIDC_callback=$oidc_callback"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CHECK IF MINIO IS INSTALLED, IF NOT INSTALL IT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing MinIO if needed..." --weight=18
|
||||
|
||||
if ! yunohost app list | grep -q "id: minio"; then
|
||||
echo "MinIO is not installed. Installing... "
|
||||
yunohost tools update
|
||||
if yunohost app list | grep -q "$minio_domain"; then
|
||||
ynh_die "The domain provided for MinIO is already used by another app. Please chose another one !"
|
||||
fi
|
||||
yunohost app install https://github.com/YunoHost-Apps/minio_ynh --force --args "domain=$minio_domain&is_public=true&admin=$minio_admin&password=$minio_password"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
@ -84,7 +106,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
|
@ -110,7 +132,7 @@ ynh_secure_remove --file="$mc_path/outlinestorage"
|
|||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||
|
||||
# Install nodejs
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
@ -134,7 +156,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
|||
#=================================================
|
||||
|
||||
ynh_secure_remove --file="$final_path/.env"
|
||||
ynh_script_progression --message="Updating the configuration file..." --time --weight=1
|
||||
ynh_script_progression --message="Updating the configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
|
||||
|
||||
|
@ -144,7 +166,7 @@ chown $app:$app "$final_path/.env"
|
|||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
@ -152,28 +174,28 @@ systemctl enable $app.service --quiet
|
|||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logs..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the logs..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Outline server" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
|
@ -182,7 +204,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -190,4 +212,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --time --last
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -24,16 +24,19 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|||
language_key=$(ynh_app_setting_get --app=$app --key=language_key)
|
||||
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
|
||||
utils_secret=$(ynh_app_setting_get --app=$app --key=utils_secret)
|
||||
minio_domain=$(ynh_app_setting_get --app="minio" --key=domain)
|
||||
minio_admin=$(ynh_app_setting_get --app="minio" --key=admin)
|
||||
minio_password=$(ynh_app_setting_get --app="minio" --key=password)
|
||||
minio_key=$(ynh_app_setting_get --app="minio" --key=minio_key)
|
||||
mc_path=$(ynh_app_setting_get --app="minio" --key=mc_path)
|
||||
dex_domain=$(ynh_app_setting_get --app="minio" --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app="minio" --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app="minio" --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app="minio" --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app="minio" --key=oidc_callback)
|
||||
minio_domain=$(ynh_app_setting_get --app=$app --key=minio_domain)
|
||||
minio_admin=$(ynh_app_setting_get --app=$app --key=minio_admin)
|
||||
minio_password=$(ynh_app_setting_get --app=$app --key=minio_password)
|
||||
mc_path=$(ynh_app_setting_get --app=$app --key=mc_path)
|
||||
dex_app=$(ynh_app_setting_get --app=$app --key=dex_app)
|
||||
dex_domain=$(ynh_app_setting_get --app=$app --key=dex_domain)
|
||||
dex_path=$(ynh_app_setting_get --app=$app --key=dex_path)
|
||||
oidc_secret=$(ynh_app_setting_get --app=$app --key=oidc_secret)
|
||||
oidc_name=$(ynh_app_setting_get --app=$app --key=oidc_name)
|
||||
oidc_callback=$(ynh_app_setting_get --app=$app --key=oidc_callback)
|
||||
dex_auth_uri=$(ynh_app_setting_get --app=$app --key=dex_auth_uri)
|
||||
dex_token_uri=$(ynh_app_setting_get --app=$app --key=dex_token_uri)
|
||||
dex_user_uri=$(ynh_app_setting_get --app=$app --key=dex_user_uri)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -44,7 +47,7 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -60,14 +63,14 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
@ -78,7 +81,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
@ -91,7 +94,7 @@ chown -R $app:www-data "$final_path"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
@ -99,7 +102,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
|
@ -112,26 +115,26 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
|
|||
#=================================================
|
||||
# UPGRADE YARN DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --time --weight=10
|
||||
ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=10
|
||||
|
||||
pushd "$final_path"
|
||||
ynh_use_nodejs
|
||||
ynh_script_progression --message="Fetching Yarn dev dependencies... This can be very long, be patient !" --time --weight=5
|
||||
ynh_script_progression --message="Fetching Yarn dev dependencies... This can be very long, be patient !" --weight=5
|
||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --no-optional --frozen-lockfile 2>&1
|
||||
ynh_script_progression --message="Cleaning cache... " --time --weight=1
|
||||
ynh_script_progression --message="Cleaning cache... " --weight=1
|
||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean 2>&1
|
||||
ynh_script_progression --message="Building Yarn dev dependencies... This can be very long, be patient !" --time --weight=5
|
||||
ynh_script_progression --message="Building Yarn dev dependencies... This can be very long, be patient !" --weight=5
|
||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn build 2>&1
|
||||
ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --time --weight=5
|
||||
ynh_script_progression --message="Fetching Yarn production dependencies... This can be very long, be patient !" --weight=5
|
||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --production=true --frozen-lockfile 2>&1
|
||||
ynh_script_progression --message="Cleaning cache... " --time --weight=1
|
||||
ynh_script_progression --message="Cleaning cache... " --weight=1
|
||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean 2>&1
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --time --weight=1
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
|
||||
|
||||
|
@ -151,7 +154,7 @@ popd
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
@ -161,7 +164,7 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
@ -169,21 +172,21 @@ ynh_use_logrotate --non-append
|
|||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Outline server" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -191,4 +194,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue