1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kiwiirc_ynh.git synced 2024-09-03 19:35:59 +02:00
This commit is contained in:
ericgaspar 2021-07-09 07:31:16 +02:00
parent 9f10232908
commit 2171aaba23
5 changed files with 78 additions and 83 deletions

View file

@ -1,9 +1,9 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
admin="john" (USER) admin="john"
is_public=1 (PUBLIC|public=1|private=0) is_public=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -14,10 +14,7 @@
upgrade=1 upgrade=1
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0
change_url=1 change_url=1
;;; Levels
Level 5=auto
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none

View file

@ -13,7 +13,7 @@
"name": "" "name": ""
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.8.1" "yunohost": ">= 4.2.4"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
@ -24,29 +24,17 @@
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": {
"en": "Choose a domain name for KiwiIRC",
"fr": "Choisissez un nom de domaine pour KiwiIRC"
},
"example": "domain.org" "example": "domain.org"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": {
"en": "Choose a path for KiwiIRC",
"fr": "Choisissez un chemin pour KiwiIRC"
},
"example": "/kiwiirc", "example": "/kiwiirc",
"default": "/kiwiirc" "default": "/kiwiirc"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"ask": {
"en": "Is it a public site?",
"fr": "Est-ce un site public ?"
},
"help": { "help": {
"en": "If enabled, KiwiIRC will be accessible by people who do not have an account. This can be changed later via the webadmin.", "en": "If enabled, KiwiIRC will be accessible by people who do not have an account. This can be changed later via the webadmin.",
"fr": "Si cette case est cochée, KiwiIRC sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." "fr": "Si cette case est cochée, KiwiIRC sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."

View file

@ -40,9 +40,6 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
mkdir -p /var/www/webircgateway
webircgateway_path=/var/www/webircgateway
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
@ -61,6 +58,14 @@ ynh_script_progression --message="Configuring firewall..." --weight=1
port=$(ynh_find_port --port=7778) port=$(ynh_find_port --port=7778)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -70,8 +75,26 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
#CREAT GATEWAYPATH
#=================================================
ynh_script_progression --message="Setting up gatheway path..." --weight=2
webircgateway_path=/var/www/webircgateway
mkdir -p $webircgateway_path
ynh_app_setting_set --app=$app --key=webircgateway_path --value=$webircgateway_path
mv ../sources/webircgateway/* $webircgateway_path mv ../sources/webircgateway/* $webircgateway_path
chmod 750 "$webircgateway_path"
chmod -R o-rwx "$webircgateway_path"
chown -R $app:www-data "$webircgateway_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -80,14 +103,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -101,24 +116,9 @@ ynh_add_systemd_config
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." ynh_script_progression --message="Modifying a config file..."
cp ../conf/config.json.example "$final_path/static/config.json" ynh_add_config --template="../conf/config.json.example" --destination="$final_path/static/config.json"
# Main config File ynh_add_config --template="../conf/config.conf.example" --destination="$webircgateway_path/config.conf"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/static/config.json"
cp ../conf/config.conf.example "$webircgateway_path/config.conf"
ynh_store_file_checksum --file="$final_path/static/config.json"
ynh_store_file_checksum --file="$webircgateway_path/config.conf"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R $app:$app $final_path
chown -R www-data:www-data $webircgateway_path
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
@ -143,7 +143,7 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Make app public if necessary or protect it # Make app public if necessary or protect it
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
ynh_permission_update --permission "main" --add "visitors" ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================

View file

@ -47,6 +47,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" 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..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
@ -54,21 +62,9 @@ ynh_script_progression --message="Restoring KiwiIRC main directory..." --weight=
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= chmod 750 "$final_path"
# RECREATE THE DEDICATED USER chmod -R o-rwx "$final_path"
#================================================= chown -R $app:www-data "$final_path"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..." --weight=1
# Restore permissions on app files
chown -R $app:$app $final_path
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD

View file

@ -43,6 +43,32 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If final_path doesn't exist, create it
#if [ -z "$final_path" ]; then
# final_path=/var/www/$app
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
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"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -70,6 +96,10 @@ then
ynh_secure_remove --file="$tmpdir" ynh_secure_remove --file="$tmpdir"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -78,22 +108,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
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
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions on app files
chown -R $app:$app $final_path
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================