2024-07-28 01:18:44 +02:00

92 lines
3.2 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INITIALIZE AND STORE SETTINGS
#=================================================
ldap_user="svc_${app}_ldap"
ldap_password=$(ynh_string_random --length=8)
ynh_app_setting_set --app="$app" --key=ldap_user --value="$ldap_user"
ynh_app_setting_set --app="$app" --key=ldap_password --value="$ldap_password"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing NodeJS..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
ynh_use_nodejs
#=================================================
# DISABLED: CREATE A POSTGRESQL DATABASE
#=================================================
# ynh_script_progression --message="Creating a PostgreSQL database..."
# ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_script_progression --message="Url: $git_url"
# Download, check integrity, uncompress and patch the source from app.src
# ynh_setup_source --dest_dir="$install_dir"
git clone "$git_url" "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# ADD A CONFIGURATION
#=================================================
# ynh_script_progression --message="Adding a configuration file..."
# ynh_add_config --template="config.sample.yml" --destination="$install_dir/config.yml"
# chmod 400 "$install_dir/config.yml"
# chown "$app:$app" "$install_dir/config.yml"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
# ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# # Create a dedicated NGINX config
# ynh_add_nginx_config
# # Create a dedicated systemd config
# ynh_add_systemd_config
# yunohost service add "$app" --description="$app daemon for Custom Node.js App" --log="/var/log/$app/$app.log"
#=================================================
# CREATE LDAP USER
#=================================================
# ynh_script_progression --message="Creating LDAP user..."
# yunohost user create "$ldap_user" --fullname "SvcWikijsLdap" --domain "$domain" --password "$ldap_password" -q 0
#=================================================
# START SYSTEMD SERVICE
#=================================================
# ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
# ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="HTTP Server:"
#=================================================
# END OF SCRIPT
#=================================================
# ynh_script_progression --message="Installation of $app completed"