diff --git a/conf/config.json5 b/conf/config.json5 new file mode 100644 index 0000000..0ad4358 --- /dev/null +++ b/conf/config.json5 @@ -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', + } + */ +} diff --git a/conf/systemd.service b/conf/systemd.service index d1cc2b3..b026b2d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,11 +9,7 @@ Group=__APP__ WorkingDirectory=__FINALPATH__/ Environment=NODE_ENV=production Environment="__YNH_NODE_LOAD_PATH__" -ExecStart=__YARN_BIN_DIR__/wetty \ - --host 127.0.0.1 \ - --port __PORT__ \ - --base __PATH_URL__/ \ - --sshhost __DOMAIN__ +ExecStart=__YARN_BIN_DIR__/wetty --conf __FINALPATH__/config.json5 [Install] WantedBy=multi-user.target diff --git a/scripts/change_url b/scripts/change_url index 6c4c0b6..9b6c929 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -102,35 +102,16 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# BUILD YARN DEPENDENCIES +# CHANGE URL IN CONFIG FILE #================================================= -ynh_script_progression --message="Rebuilding Yarn dependencies..." --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 +ynh_script_progression --message="Editing config file..." --weight=2 domain="$new_domain" path_url="$new_path" +# port is already defined in this file -# Create a dedicated systemd config -ynh_backup_if_checksum_is_different --file="/etc/systemd/system/$app.service" -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 +ynh_backup_if_checksum_is_different --file="$final_path/config.json5" +ynh_add_config --template="config.json5" --destination="$final_path/config.json5" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index dc38a54..cbf4bf7 100755 --- a/scripts/install +++ b/scripts/install @@ -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 ynh_setup_source --dest_dir="$final_path" +ynh_add_config --template="config.json5" --destination="$final_path/config.json5" + #================================================= # NGINX CONFIGURATION #================================================= @@ -119,8 +121,8 @@ popd || return 1 ynh_script_progression --message="Configuring the systemd service..." --weight=1 # Create a dedicated 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" +test -n "${ynh_node_load_PATH}${yarn_bin_dir}" +ynh_add_systemd_config --others_var="ynh_node_load_PATH yarn_bin_dir" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d21bfcb..8435793 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -93,6 +93,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]; then ynh_setup_source --dest_dir="$final_path" fi +ynh_add_config --template="config.json5" --destination="$final_path/config.json5" + #================================================= # NGINX CONFIGURATION #================================================= @@ -130,8 +132,8 @@ popd || return 1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated 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" +test -n "${ynh_node_load_PATH}${yarn_bin_dir}" +ynh_add_systemd_config --others_var="ynh_node_load_PATH yarn_bin_dir" #================================================= # GENERIC FINALIZATION