1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/archivebox_ynh.git synced 2024-09-03 18:15:54 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2022-01-27 21:05:27 +01:00
parent a2d626f966
commit 45bd8b5c2b
12 changed files with 48 additions and 47 deletions

4
.gitignore vendored
View file

@ -1,4 +0,0 @@
*~
*.sw[op]
@
.idea

View file

@ -15,7 +15,8 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
#upgrade=1 from_commit=CommitHash # 0.6.2~ynh9
upgrade=1 from_commit=a2d626f966bc358aea53bbe78d9fa2a0e3783c78
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0 port_already_use=0
@ -24,6 +25,5 @@
Email= Email=
Notification=none Notification=none
;;; Upgrade options ;;; Upgrade options
; commit=CommitHash ; commit=a2d626f966bc358aea53bbe78d9fa2a0e3783c78
name=Name and date of the commit. name=0.6.2~ynh9
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,10 +1,5 @@
location __PATH__/ { location __PATH__/ {
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_set_header Accept-Encoding ""; proxy_set_header Accept-Encoding "";
try_files $uri @proxy; try_files $uri @proxy;

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Archiving solution to collect, save, and view sites you want to preserve offline

View file

@ -2,4 +2,3 @@
* required to be run at the base path / , subpaths not yet supported * required to be run at the base path / , subpaths not yet supported
* currently only tested on amd64 * currently only tested on amd64
* haven't yet implemented single-sign or LDAP integration * haven't yet implemented single-sign or LDAP integration

View file

@ -21,14 +21,14 @@
"email": "max@mfowler.info" "email": "max@mfowler.info"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.7" "yunohost": ">= 4.3.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script

View file

@ -109,6 +109,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -137,9 +136,13 @@ archivebox_cmd="$final_path/venv/bin/archivebox"
#================================================= #=================================================
# INSTALL NODE DEPENDENCIES # INSTALL NODE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Install node dependencies..."
cp ../conf/package.json "$final_path/package.json" cp ../conf/package.json "$final_path/package.json"
cp ../conf/package-lock.json "$final_path/package-lock.json" cp ../conf/package-lock.json "$final_path/package-lock.json"
cd $final_path; ynh_npm ci pushd $final_path
ynh_npm ci
popd
ynh_node_path=$ynh_node ynh_node_path=$ynh_node
@ -153,7 +156,6 @@ ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir mkdir -p $datadir
# permissions
chmod 750 "$datadir" chmod 750 "$datadir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir" chown -R $app:www-data "$datadir"
@ -183,7 +185,7 @@ ynh_script_progression --message="Found users: $USER_EXISTS" --weight=1
if [ $USER_EXISTS -eq 1 ] if [ $USER_EXISTS -eq 1 ]
then then
ynh_script_progression --message="User already exists: setting admin password" --weight=1 ynh_script_progression --message="User already exists: setting admin password" --weight=1
ynh_exec_as $app /usr/bin/expect<<EOF ynh_exec_as $app /usr/bin/expect<<EOF
set force_conservative 0 ; set force_conservative 0 ;
set timeout -1 set timeout -1
@ -196,8 +198,8 @@ send -- "$password\r"
expect eof expect eof
EOF EOF
else else
ynh_script_progression --message="Creating new archivebox superuser: $admin" --weight=1 ynh_script_progression --message="Creating new archivebox superuser: $admin" --weight=1
ynh_exec_as $app /usr/bin/expect<<EOF ynh_exec_as $app /usr/bin/expect<<EOF
set force_conservative 0 ; set force_conservative 0 ;
set timeout -1 set timeout -1
spawn sh -c "cd $datadir && $archivebox_cmd manage createsuperuser --username $admin --email $admin_mail" spawn sh -c "cd $datadir && $archivebox_cmd manage createsuperuser --username $admin --email $admin_mail"

View file

@ -21,6 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -44,12 +45,12 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
ynh_remove_systemd_config ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1 ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove metapackage and its dependencies # Remove the app-specific logrotate config
ynh_remove_app_dependencies ynh_remove_logrotate
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
@ -59,6 +60,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -68,12 +80,12 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove the app-specific logrotate config # Remove metapackage and its dependencies
ynh_remove_logrotate ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -120,10 +119,8 @@ yunohost service add $app --description="Self-hosted internet archiving" --log="
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Ensuring systemd log folder is restored..." --weight=1
mkdir -p /var/log/$app
ynh_script_progression --message="Starting a systemd service..." --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" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================

View file

@ -25,7 +25,7 @@ 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)
language=$(ynh_app_setting_get --app=$app --key=language) language=$(ynh_app_setting_get --app=$app --key=language)
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)
#================================================= #=================================================
# SET CORRECT NODE VERSION # SET CORRECT NODE VERSION
@ -35,6 +35,7 @@ ynh_use_nodejs --nodejs_version=$nodejs_version
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -81,6 +82,14 @@ 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 --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -97,8 +106,6 @@ fi
# UPGRADE VIA PIP # UPGRADE VIA PIP
#================================================= #=================================================
datadir=/home/yunohost.app/$app
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading via pip" --weight=1 ynh_script_progression --message="Upgrading via pip" --weight=1
@ -127,14 +134,6 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================