mirror of
https://github.com/YunoHost-Apps/armadietto_ynh.git
synced 2024-09-03 18:06:18 +02:00
wip v0.0.2-beta update all scripts
This commit is contained in:
parent
cdf0afe8a8
commit
83264aab02
9 changed files with 195 additions and 245 deletions
|
@ -10,25 +10,26 @@
|
|||
admin="armadietto"
|
||||
language="fr"
|
||||
is_public=1
|
||||
is_signup=0
|
||||
is_signup=true
|
||||
port="8008"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=0
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=0
|
||||
upgrade=0 from_commit=CommitHash
|
||||
backup_restore=0
|
||||
setup_nourl=1
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
# 0.0.2-beta.10~ynh1
|
||||
upgrade=1 from_commit=27894600799b8b04f71e7ec219798e34512e51b0
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
port_already_use=1
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&is_signup=0&port=8008&
|
||||
; commit=27894600799b8b04f71e7ec219798e34512e51b0
|
||||
name= Upgrade to version 0.0.2-beta.10~ynh1
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&is_signup=true&port=8008&
|
||||
|
|
10
conf/config.sample.yml
Normal file
10
conf/config.sample.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
#=================================================
|
||||
# ARMADIETTO CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
|
||||
final_path: __FINALPATH__
|
||||
datadir: __DATADIR__
|
||||
port: __PORT__
|
||||
domain: __DOMAIN__
|
||||
|
|
@ -7,9 +7,9 @@ Type=simple
|
|||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=__FINALPATH__/
|
||||
ExecStart=__NODEJS_PATH__/node __FINALPATH__/server.js
|
||||
ExecStart=__YNH_NODE__ __FINALPATH__/server
|
||||
Restart=always
|
||||
Environment=PATH=/usr/bin:/usr/local/bin:__NODEJS_PATH__
|
||||
Environment=__YNH_NODE_LOAD_PATH__
|
||||
Environment=NODE_ENV=production
|
||||
|
||||
# Sandboxing options to harden security
|
||||
|
|
|
@ -1,78 +1,16 @@
|
|||
|
||||
## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button
|
||||
## Those panels let user configure some params on their apps using a friendly interface,
|
||||
## and remove the need to manually edit files from the command line.
|
||||
|
||||
## From a packager perspective, this .toml is coupled to the scripts/config script,
|
||||
## which may be used to define custom getters/setters. However, most use cases
|
||||
## should be covered automagically by the core, thus it may not be necessary
|
||||
## to define a scripts/config at all!
|
||||
|
||||
## -----------------------------------------------------------------------------
|
||||
## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and
|
||||
## do not overwhelm the admin with tons of misunderstandable or advanced settings.
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
## The top level describe the entire config panels screen.
|
||||
|
||||
## The version is a required property.
|
||||
## Here a small reminder to associate config panel version with YunoHost version
|
||||
## | Config | YNH | Config panel small change log |
|
||||
## | ------ | --- | ------------------------------------------------------- |
|
||||
## | 0.1 | 3.x | 0.1 config script not compatible with YNH >= 4.3 |
|
||||
## | 1.0 | 4.3.x | The new config panel system with 'bind' property |
|
||||
version = "1.0"
|
||||
name= "Armadietto configuration panel"
|
||||
|
||||
## (optional) i18n property let you internationalize questions, however this feature
|
||||
## is only available in core configuration panel (like yunohost domain config).
|
||||
## So in app config panel this key is ignored for now, but you can internationalize
|
||||
## by using a lang dictionary (see property name bellow)
|
||||
# i18n = "prefix_translation_key"
|
||||
|
||||
################################################################################
|
||||
#### ABOUT PANELS
|
||||
################################################################################
|
||||
|
||||
## The next level describes web admin panels
|
||||
## You have to choose an ID for each panel, in this example the ID is "main"
|
||||
## Keep in mind this ID will be used in CLI to refer to your question, so choose
|
||||
## something short and meaningfull.
|
||||
## In the webadmin, each panel corresponds to a distinct tab / form
|
||||
[main]
|
||||
name = "Armadietto signup configuration"
|
||||
|
||||
## Define the label for your panel
|
||||
## Internationalization works similarly to the 'description' and 'ask' questions in the manifest
|
||||
# name.en = "Main configuration"
|
||||
# name.fr = "Configuration principale"
|
||||
[main.is_signup]
|
||||
name = "Signup configuration"
|
||||
|
||||
## (optional) If you need to trigger a service reload-or-restart after the user
|
||||
## change a question in this panel, you can add your service in the list.
|
||||
services = ["__APP__"]
|
||||
# or services = ["nginx", "__APP__"] to also reload-or-restart nginx
|
||||
|
||||
## (optional) This help properties is a short help displayed on the same line
|
||||
## than the panel title but not displayed in the tab.
|
||||
# help = ""
|
||||
|
||||
############################################################################
|
||||
#### ABOUT SECTIONS
|
||||
############################################################################
|
||||
|
||||
## A panel is composed of one or several sections.
|
||||
##
|
||||
## Sections are meant to group questions together when they correspond to
|
||||
## a same subtopic. This impacts the rendering in terms of CLI prompts
|
||||
## and HTML forms
|
||||
##
|
||||
## You should choose an ID for your section, and prefix it with the panel ID
|
||||
## (Be sure to not make a typo in the panel ID, which would implicitly create
|
||||
## an other entire panel)
|
||||
##
|
||||
## We use the context of pepettes_ynh as an example,
|
||||
## which is a simple donation form app written in python,
|
||||
## and for which the admin will want to edit the configuration
|
||||
[main.customization]
|
||||
|
||||
## (optional) Defining a proper title for sections is not mandatory
|
||||
## and depends on the exact rendering you're aiming for the CLI / webadmin
|
||||
name = "PLOP"
|
||||
[main.is_signup.signup]
|
||||
ask.en = "Allow signups?"
|
||||
ask.fr = "Accepter les inscriptions ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help.en = "Would you like to allow visitors to register and create an account?"
|
||||
help.fr = "Souhaitez-vous autoriser les visiteurs à s'inscrire et créer un compte ?"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Armadietto is a remoteStorage server written for Node.js.",
|
||||
"fr": "Armadietto est un serveur remoteStorage écrit pour node.js."
|
||||
},
|
||||
"version": "1.0.1~ynh2",
|
||||
"version": "0.0.2-beta.10~ynh2",
|
||||
"url": "https://github.com/remotestorage/armadietto",
|
||||
"upstream": {
|
||||
"license": "MIT",
|
||||
|
@ -58,7 +58,7 @@
|
|||
"en": "Would you like to allow visitors to register and create an account?",
|
||||
"fr": "Souhaitez-vous autoriser les visiteurs à s'inscrire et créer un compte ?"
|
||||
},
|
||||
"default": false
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -37,11 +37,6 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
||||
### to be backuped and not an actual copy of any file. The actual backup that
|
||||
### creates and fill the archive with the files happens in the core after this
|
||||
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -52,7 +47,12 @@ ynh_backup --src_path="$final_path"
|
|||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$datadir" --is_big
|
||||
ynh_backup --src_path="$datadir"
|
||||
|
||||
# BACKUP THE ARMADIETTO SERVER
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path/server.js"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
|
@ -60,28 +60,12 @@ ynh_backup --src_path="$datadir" --is_big
|
|||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
# ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
# ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
# ynh_backup --src_path="/etc/$app/"
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -31,6 +31,9 @@ is_signup=$YNH_APP_ARG_IS_SIGNUP
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Define app's data directory
|
||||
datadir="/home/yunohost.app/${app}/storage"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
|
@ -56,7 +59,9 @@ ynh_script_progression --message="Storing installation settings..." --weight=1
|
|||
|
||||
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=final_path --value=final_path
|
||||
ynh_app_setting_set --app=$app --key=is_signup --value=$is_signup
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -115,32 +120,36 @@ ynh_script_progression --message="Configuring system user..." --weight=1
|
|||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml"
|
||||
|
||||
chmod 400 "$final_path/config.yml"
|
||||
chown $app:$app "$final_path/config.yml"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service"
|
||||
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
|
||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service"
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# DEFINE ARMADIETTO OPTIONS & CREATE DIRECTORY FOR DATA
|
||||
# SETUP ARMADIETTO AS A SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring armadietto options..." --weight=1
|
||||
ynh_script_progression --message="Configuring armadietto as a service..." --weight=1
|
||||
|
||||
# Define armadietto module path
|
||||
modulepath="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
|
||||
|
||||
# Define app's data directory
|
||||
datadir="/home/yunohost.app/${app}/storage"
|
||||
|
||||
# Create app folders
|
||||
# Create app data folder
|
||||
mkdir -p "$datadir"
|
||||
|
||||
# Using Armadietto as a service in a basic node server
|
||||
cp -f ../conf/server.js "$final_path/server.js"
|
||||
|
||||
ynh_replace_string --match_string="__MODULE_PATH__" --replace_string="$modulepath" --target_file="$final_path/server.js"
|
||||
|
@ -154,10 +163,11 @@ ynh_replace_string --match_string="__SIGNUP__" --replace_string="$is_signup" --
|
|||
#=================================================
|
||||
ynh_script_progression --message="Install armadietto with npm..." --weight=1
|
||||
|
||||
cd $final_path
|
||||
npm -g i armadietto
|
||||
pushd $final_path
|
||||
ynh_npm -g i armadietto
|
||||
popd
|
||||
|
||||
ynh_script_progression --message="Armadietto installed..." --weight=1
|
||||
ynh_script_progression --message="Armadietto installed..."
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -185,14 +195,6 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|||
|
||||
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
# ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
@ -206,17 +208,6 @@ then
|
|||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
### N.B. : the following extra permissions only make sense if your app
|
||||
### does have for example an admin interface or an API.
|
||||
|
||||
# Only the admin can access the admin panel of the app (if the app has an admin panel)
|
||||
# ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
|
||||
|
||||
# Everyone can access the API part
|
||||
# We don't want to display the tile in the SSO so we put --show_tile="false"
|
||||
# And we don't want the YunoHost admin to be able to remove visitors group to this permission, so we put --protected="true"
|
||||
# ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
117
scripts/restore
117
scripts/restore
|
@ -41,6 +41,14 @@ ynh_script_progression --message="Validating restoration parameters..." --weight
|
|||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=4
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
|
@ -65,54 +73,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
|||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||
# such that the appropriate users (e.g. maybe www-data) can access
|
||||
# files in some cases.
|
||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
||||
# this will be treated as a security issue.
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p $datadir
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||
# such that the appropriate users (e.g. maybe www-data) can access
|
||||
# files in some cases.
|
||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
||||
# this will be treated as a security issue.
|
||||
chmod 700 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:$app "$datadir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
# ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
|
||||
|
||||
# ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
||||
# ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
||||
# ynh_systemd_action --action=restart --service_name=fail2ban
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
@ -121,6 +81,44 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
|
|||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE ARMADIETTO AS A SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring armadietto as a service..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$final_path/server.js" --not_mandatory
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
#=================================================
|
||||
# REINSTALL ARMADIETTO
|
||||
#=================================================
|
||||
ynh_script_progression --message="REinstall armadietto with npm..." --weight=1
|
||||
|
||||
pushd $final_path
|
||||
ynh_npm -g i armadietto
|
||||
popd
|
||||
|
||||
ynh_script_progression --message="Armadietto reinstalled..."
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Secure files and directories" --weight=1
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod 0700 $datadir && chown $app:$app $datadir
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
@ -129,24 +127,21 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|||
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# START ARMADIETTO
|
||||
#=================================================
|
||||
ynh_script_progression --message="Start armadietto web server..." --weight=1
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
115
scripts/upgrade
115
scripts/upgrade
|
@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
is_signup=$(ynh_app_setting_get --app=$app --key=signup)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -59,7 +60,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
# ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
#
|
||||
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
|
||||
|
@ -79,8 +80,6 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
#fi
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -90,47 +89,70 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
|
|||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
# CHECK AND CREATE FINAL_PATH
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up and create final app path..." --weight=1
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
# ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
fi
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||
# such that the appropriate users (e.g. maybe www-data) can access
|
||||
# files in some cases.
|
||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
||||
# this will be treated as a security issue.
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$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
|
||||
# Create final_path
|
||||
mkdir -p "$final_path"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=4
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_use_nodejs
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml"
|
||||
|
||||
chmod 400 "$final_path/config.yml"
|
||||
chown $app:$app "$final_path/config.yml"
|
||||
|
||||
#=================================================
|
||||
# DEFINE ARMADIETTO OPTIONS & CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring armadietto as a service..." --weight=1
|
||||
|
||||
# Define armadietto module path
|
||||
modulepath="$node_version_path/$nodejs_version/lib/node_modules/armadietto/lib"
|
||||
|
||||
# Create app data folder
|
||||
mkdir -p "$datadir"
|
||||
|
||||
# Using Armadietto as a service in a basic node server
|
||||
cp -f ../conf/server.js "$final_path/server.js"
|
||||
|
||||
ynh_replace_string --match_string="__MODULE_PATH__" --replace_string="$modulepath" --target_file="$final_path/server.js"
|
||||
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$final_path/server.js"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/server.js"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/server.js"
|
||||
ynh_replace_string --match_string="__SIGNUP__" --replace_string="$is_signup" --target_file="$final_path/server.js"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE ARMADIETTO
|
||||
#=================================================
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrade armadietto with npm..." --weight=1
|
||||
|
||||
pushd $final_path
|
||||
ynh_npm -g i armadietto
|
||||
popd
|
||||
|
||||
ynh_script_progression --message="Armadietto upgraded..."
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
|
@ -142,13 +164,13 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|||
### The file will automatically be backed-up if it's found to be manually modified (because
|
||||
### ynh_add_config keeps track of the file's checksum)
|
||||
|
||||
ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file"
|
||||
# ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file"
|
||||
|
||||
# FIXME: this should be handled by the core in the future
|
||||
# You may need to use chmod 600 instead of 400,
|
||||
# for example if the app is expected to be able to modify its own config
|
||||
chmod 400 "$final_path/some_config_file"
|
||||
chown $app:$app "$final_path/some_config_file"
|
||||
# chmod 400 "$final_path/some_config_file"
|
||||
# chown $app:$app "$final_path/some_config_file"
|
||||
|
||||
### For more complex cases where you want to replace stuff using regexes,
|
||||
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||
|
@ -167,6 +189,23 @@ ynh_add_systemd_config
|
|||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Secure files and directories" --weight=1
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod 0700 $datadir && chown $app:$app $datadir
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
@ -181,14 +220,6 @@ 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"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE FAIL2BAN
|
||||
#=================================================
|
||||
# ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue