1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/komga_ynh.git synced 2024-09-03 19:36:07 +02:00
This commit is contained in:
ericgaspar 2021-07-08 18:57:02 +02:00
parent 47df36978c
commit 72831a8719
9 changed files with 67 additions and 101 deletions

View file

@ -1,12 +1,9 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
is_public=1 (PUBLIC|public=1|private=0) is_public=1
port="8080" (PORT) port="8080"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -17,7 +14,6 @@
upgrade=1 upgrade=1
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0
change_url=1 change_url=1
;;; Options ;;; Options
Email= Email=

View file

@ -1,6 +1,7 @@
SOURCE_URL=https://github.com/gotson/komga/releases/download/v0.87.4/komga-0.87.4.jar SOURCE_URL=https://github.com/gotson/komga/releases/download/v0.106.1/komga-0.106.1.jar
SOURCE_SUM=35ff050b912d516e8026e22a85deb5e76d70744d520d7e92203192fb9abb4101 SOURCE_SUM=53c7c617793acbfb134ed5c3c48c1702761feb67fd6a5478bdf403f3479fc40a
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=jar SOURCE_FORMAT=jar
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=false SOURCE_EXTRACT=false
SOURCE_FILENAME=komga.jar

View file

@ -6,8 +6,8 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__
ExecStart=/usr/bin/java -jar -Xmx1g app.jar --server.port=__PORT__ --server.servlet.context-path="__PATH__/" ExecStart=/usr/bin/java -jar -Xmx1g komga.jar --server.port=__PORT__ --server.servlet.context-path="__PATH__"
Restart=on-failure Restart=on-failure
RestartSec=10 RestartSec=10

View file

@ -16,7 +16,7 @@
"url": "https://navan.dev" "url": "https://navan.dev"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.3" "yunohost": ">= 4.2.4"
}, },
"services": [ "services": [
"nginx" "nginx"
@ -26,29 +26,17 @@
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": {
"en": "Choose a domain name for Komga",
"fr": "Choisissez un nom de domaine pour Komga"
},
"example": "example.com" "example": "example.com"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": {
"en": "Choose a path for Komga",
"fr": "Choisissez un chemin pour Komga"
},
"example": "/komga", "example": "/komga",
"default": "/komga" "default": "/komga"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true "default": true
} }
] ]

View file

@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -46,7 +47,7 @@ ynh_backup --src_path="$final_path"
# BACKUP THE Database DIR # BACKUP THE Database DIR
#================================================= #=================================================
ynh_backup --src_path="/home/komga" ynh_backup --src_path="$datadir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -67,6 +67,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -76,6 +84,11 @@ 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"
chmod +x $final_path/komga.jar
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -85,46 +98,27 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=2 ynh_script_progression --message="Creating a data directory..." --weight=1
# Create a system user datadir=/home/yunohost.app/$app
ynh_system_user_create --username=$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir
#================================================= mkdir -p $datadir/.komga
# SPECIFIC SETUP
#=================================================
# CREATE DIRECTORIES
#=================================================
mkdir -p /home/$app/.komga/ chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_replace_string --match_string=__PORT__ --replace_string="$port" --target_file="../conf/systemd.service"
ynh_replace_string --match_string=__PATH__ --replace_string="$path_url" --target_file="../conf/systemd.service"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R $app: $final_path
chmod +x $final_path/app.jar
chown -R $app: /home/$app
chmod -R 755 /home/$app/.komga/
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================

View file

@ -56,7 +56,6 @@ ynh_script_progression --message="Removing app main directory and database..." -
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/home/komga"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -74,15 +73,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -32,6 +32,7 @@ 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)
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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -51,6 +52,14 @@ test ! -d $final_path \
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=2
# 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
#================================================= #=================================================
@ -58,28 +67,23 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= chmod 750 "$final_path"
# RESTORE THE DATABASE DIR chmod -R o-rwx "$final_path"
#================================================= chown -R $app:www-data "$final_path"
ynh_script_progression --message="Restoring the app database..." --weight=6 chmod +x $final_path/komga.jar
ynh_restore_file --origin_path="/home/komga"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 ynh_script_progression --message="Restoring the data directory..." --weight=1
# Create the dedicated user (if not existing) ynh_restore_file --origin_path="$datadir" --not_mandatory
ynh_system_user_create --username=$app
#================================================= mkdir -p $datadir
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files chmod 750 "$datadir"
chown -R $app: $final_path chmod -R o-rwx "$datadir"
chown -R $app: "/home/komga" chown -R $app:www-data "$datadir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION

View file

@ -54,6 +54,14 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" 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..." --weight=6
# 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
#================================================= #=================================================
@ -66,6 +74,11 @@ then
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod +x $final_path/komga.jar
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -81,35 +94,14 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=6
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_replace_string --match_string=__PORT__ --replace_string="$port" --target_file="../conf/systemd.service"
ynh_replace_string --match_string=__PATH__ --replace_string="$path_url" --target_file="../conf/systemd.service"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R $app: $final_path
chmod +x $final_path/app.jar
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================