mirror of
https://github.com/YunoHost-Apps/zeronet_ynh.git
synced 2024-09-03 17:46:12 +02:00
Added password to access the app because app don't work with SSO
This commit is contained in:
parent
7e44eb2dbd
commit
260a28279f
8 changed files with 39 additions and 36 deletions
|
@ -4,7 +4,7 @@
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="sub.domain.tld" (DOMAIN)
|
domain="sub.domain.tld" (DOMAIN)
|
||||||
# path="/" (PATH)
|
# path="/" (PATH)
|
||||||
admin="john" (USER)
|
password="seceret123" (USER)
|
||||||
# language="fr"
|
# language="fr"
|
||||||
# is_public="Yes" (PUBLIC|public=Yes|private=No)
|
# is_public="Yes" (PUBLIC|public=Yes|private=No)
|
||||||
# is_public=0 (PUBLIC|public=1|private=0)
|
# is_public=0 (PUBLIC|public=1|private=0)
|
||||||
|
|
|
@ -6,7 +6,7 @@ After=network.target
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__
|
WorkingDirectory=__FINALPATH__
|
||||||
ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log
|
ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log --ui_password __PASSWORD__
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
KillMode=process
|
KillMode=process
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
|
@ -32,14 +32,15 @@
|
||||||
"example": "zeronet.domain.tld"
|
"example": "zeronet.domain.tld"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "password",
|
||||||
"type": "user",
|
"type": "password",
|
||||||
|
"optional": true,
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose an admin user (the one who will be able to access the admin interface)",
|
"en": "Set the password for the Zeronet.",
|
||||||
"fr": "Choisissez l'administrateur (seul autorisé à accéder à l'interface d'administration)"
|
"fr": "Définissez le mot de passe pour votre Zeronet."
|
||||||
},
|
},
|
||||||
"example": "john doe"
|
"example": "myreallystrengthpassword"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="python3-msgpack python3-socks python3-gevent"
|
pkg_dependencies="python3-venv python3-pip"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
|
@ -26,7 +26,7 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
password=$YNH_APP_ARG_PASSWORD
|
||||||
|
|
||||||
|
|
||||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||||
|
@ -69,9 +69,8 @@ ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||||
|
ynh_app_setting_set --app=$app --key=password --value=$password
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -110,7 +109,8 @@ ynh_script_progression --message="Installing dependencies..."
|
||||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
|
|
||||||
pip3 install msgpack-python gevent
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
pip3 install msgpack-python gevent base58 merkletools
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -162,21 +162,18 @@ ynh_script_progression --message="Configuring a systemd service..."
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP APPLICATION WITH CURL
|
# SETUP APPLICATION PERMISSIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
### Use these lines only if the app installation needs to be finalized through
|
# Enable password authentication for Zeronet
|
||||||
### web forms. We generally don't want to ask the final user,
|
mv $final_path/plugins/disabled-UiPassword $final_path/plugins/UiPassword
|
||||||
### so we're going to use curl to automatically fill the fields and submit the
|
|
||||||
### forms.
|
|
||||||
|
|
||||||
# Set right permissions for curl install
|
# Set right permissions
|
||||||
mkdir -p $datadir/data
|
mkdir -p $datadir/data
|
||||||
mkdir -p $datadir/log
|
mkdir -p $datadir/log
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
chown -R $app: $datadir
|
chown -R $app: $datadir
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -190,7 +187,7 @@ ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
|
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
|
||||||
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
|
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
|
||||||
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
|
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
|
||||||
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir"
|
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password"
|
||||||
|
|
||||||
yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port"
|
yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port"
|
||||||
|
|
||||||
|
@ -231,9 +228,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
|
|
||||||
# Restrict access to admin only
|
# Allow the app to be public
|
||||||
#yunohost app addaccess --users=$admin $app
|
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -50,7 +50,7 @@ ynh_script_progression --message="Removing dependencies..."
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
pip3 uninstall -y msgpack-python gevent
|
pip3 uninstall -y msgpack-python gevent
|
||||||
|
ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -30,11 +30,11 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
fs_port=$(ynh_app_setting_get --app=$app --key=fs_port)
|
fs_port=$(ynh_app_setting_get --app=$app --key=fs_port)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -68,7 +68,7 @@ ynh_restore_file --origin_path="$datadir"
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create --username=$app --home_dir=$datadir -s
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
|
@ -86,7 +86,8 @@ chown -R $app: $datadir
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
pip3 install msgpack-python gevent
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
pip3 install msgpack-python gevent base58 merkletools
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
|
@ -101,7 +102,7 @@ systemctl enable $app.service
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir"
|
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password"
|
||||||
yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port"
|
yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -116,8 +117,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
||||||
|
|
||||||
# Restrict access to admin only
|
# Allow the app to be public
|
||||||
yunohost app addaccess --users=$admin $app
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -18,11 +18,11 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
fs_port=$(ynh_app_setting_get --app=$app --key=fs_port)
|
fs_port=$(ynh_app_setting_get --app=$app --key=fs_port)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -108,7 +108,8 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
pip3 install msgpack-python gevent
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
pip3 install msgpack-python gevent base58 merkletools
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -116,7 +117,7 @@ pip3 install msgpack-python gevent
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create --username=$app --home_dir=$datadir -s
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -132,6 +133,9 @@ ynh_add_systemd_config
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Enable password authentication for Zeronet
|
||||||
|
mv $final_path/plugins/disabled-UiPassword $final_path/plugins/UiPassword
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
chown -R $app: $datadir
|
chown -R $app: $datadir
|
||||||
|
@ -140,7 +144,7 @@ chown -R $app: $datadir
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir"
|
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password"
|
||||||
yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port"
|
yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -155,8 +159,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
||||||
|
|
||||||
# Restrict access to admin only
|
# Allow the app to be public
|
||||||
yunohost app addaccess --users=$admin $app
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
Loading…
Add table
Reference in a new issue