mirror of
https://github.com/YunoHost-Apps/wetty_ynh.git
synced 2024-09-03 18:16:29 +02:00
Use config file instead of writing config in systemd file
This commit is contained in:
parent
de547641d6
commit
a6e87ff237
5 changed files with 44 additions and 33 deletions
30
conf/config.json5
Normal file
30
conf/config.json5
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// Extracted from Wetty sources conf/config.json5
|
||||||
|
|
||||||
|
{
|
||||||
|
ssh: {
|
||||||
|
// user: 'username', // default user to use when ssh-ing
|
||||||
|
host: '__DOMAIN__', // Server to ssh to
|
||||||
|
auth: 'password', // shh authentication, method. Defaults to "password", you can use "publickey,password" instead'
|
||||||
|
// pass: "password", // Password to use when sshing
|
||||||
|
// key: "", // path to an optional client private key, connection will be password-less and insecure!
|
||||||
|
port: 22, // Port to ssh to
|
||||||
|
knownHosts: '/dev/null', // ssh knownHosts file to use
|
||||||
|
// config: '/home/user/.wetty_ssh_config', // alternative ssh configuration file, see "-F" option in ssh(1)
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
base: '__PATH_URL__', // URL base to serve resources from
|
||||||
|
port: __PORT__, // Port to listen on
|
||||||
|
host: '127.0.0.1', // address to listen on
|
||||||
|
title: 'WeTTy - The Web Terminal Emulator', // Page title
|
||||||
|
bypassHelmet: false, // Disable Helmet security checks
|
||||||
|
},
|
||||||
|
|
||||||
|
forceSSH: false, // Force sshing to local machine over login if running as root
|
||||||
|
command: 'login', // Command to run on server. Login will use ssh if connecting to different server
|
||||||
|
/*
|
||||||
|
ssl:{
|
||||||
|
key: 'ssl.key',
|
||||||
|
cert: 'ssl.cert',
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
|
@ -9,11 +9,7 @@ Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__FINALPATH__/
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
Environment="__YNH_NODE_LOAD_PATH__"
|
Environment="__YNH_NODE_LOAD_PATH__"
|
||||||
ExecStart=__YARN_BIN_DIR__/wetty \
|
ExecStart=__YARN_BIN_DIR__/wetty --conf __FINALPATH__/config.json5
|
||||||
--host 127.0.0.1 \
|
|
||||||
--port __PORT__ \
|
|
||||||
--base __PATH_URL__/ \
|
|
||||||
--sshhost __DOMAIN__
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -102,35 +102,16 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD YARN DEPENDENCIES
|
# CHANGE URL IN CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Rebuilding Yarn dependencies..." --weight=2
|
ynh_script_progression --message="Editing config file..." --weight=2
|
||||||
|
|
||||||
chown -R "$app":"$app" "$final_path"
|
|
||||||
|
|
||||||
pushd "$final_path" || return 1
|
|
||||||
ynh_use_nodejs ; set "${ynh_node_load_PATH:?}"
|
|
||||||
sudo -u "$app" env "$ynh_node_load_PATH" yarn global add wetty@"$YARN_APP_REAL_VERSION"
|
|
||||||
yarn_bin_dir="$(sudo -u "$app" env "$ynh_node_load_PATH" yarn global bin)"
|
|
||||||
popd || return 1
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring the systemd service..." --weight=1
|
|
||||||
|
|
||||||
domain="$new_domain"
|
domain="$new_domain"
|
||||||
path_url="$new_path"
|
path_url="$new_path"
|
||||||
|
# port is already defined in this file
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
ynh_backup_if_checksum_is_different --file="$final_path/config.json5"
|
||||||
ynh_backup_if_checksum_is_different --file="/etc/systemd/system/$app.service"
|
ynh_add_config --template="config.json5" --destination="$final_path/config.json5"
|
||||||
ynh_remove_systemd_config
|
|
||||||
test -n "${domain}${port}${path_url}${ynh_node_load_PATH}${yarn_bin_dir}"
|
|
||||||
ynh_add_systemd_config --others_var="domain port path_url ynh_node_load_PATH yarn_bin_dir"
|
|
||||||
ynh_store_file_checksum --file="/etc/systemd/system/$app.service"
|
|
||||||
|
|
||||||
systemctl daemon-reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
|
@ -82,6 +82,8 @@ 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"
|
||||||
|
|
||||||
|
ynh_add_config --template="config.json5" --destination="$final_path/config.json5"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -119,8 +121,8 @@ popd || return 1
|
||||||
ynh_script_progression --message="Configuring the systemd service..." --weight=1
|
ynh_script_progression --message="Configuring the systemd service..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
test -n "${domain}${port}${path_url}${ynh_node_load_PATH}${yarn_bin_dir}"
|
test -n "${ynh_node_load_PATH}${yarn_bin_dir}"
|
||||||
ynh_add_systemd_config --others_var="domain port path_url ynh_node_load_PATH yarn_bin_dir"
|
ynh_add_systemd_config --others_var="ynh_node_load_PATH yarn_bin_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -93,6 +93,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ynh_add_config --template="config.json5" --destination="$final_path/config.json5"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -130,8 +132,8 @@ popd || return 1
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
test -n "${domain}${port}${path_url}${ynh_node_load_PATH}${yarn_bin_dir}"
|
test -n "${ynh_node_load_PATH}${yarn_bin_dir}"
|
||||||
ynh_add_systemd_config --others_var="domain port path_url ynh_node_load_PATH yarn_bin_dir"
|
ynh_add_systemd_config --others_var="ynh_node_load_PATH yarn_bin_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
Loading…
Add table
Reference in a new issue