mirror of
https://github.com/YunoHost-Apps/mongo-express_ynh.git
synced 2024-09-03 19:46:04 +02:00
84 lines
2.8 KiB
Bash
Executable file
84 lines
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source ynh_mongo_db__2
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing NodeJS..." --weight=3
|
|
|
|
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
|
ynh_use_nodejs
|
|
|
|
# Install mongo server only if asked to
|
|
if [ "$mongo_version" != "None" ]; then
|
|
ynh_script_progression --message="Installing MongoDB..." --weight=3
|
|
ynh_install_mongo --mongo_version="$mongo_version"
|
|
else
|
|
# gives the mongo service name for the rest of installation
|
|
mongodb_servicename=mongod
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from amd64.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
cp "$install_dir/config.default.js" "$install_dir/config.js"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
|
chmod 400 "$install_dir/.env"
|
|
chown "$app:$app" "$install_dir/.env"
|
|
|
|
#=================================================
|
|
# BUILD NODEJS CODE
|
|
#=================================================
|
|
ynh_script_progression --message="Building NodeJS code and dependencies..." --weight=6
|
|
|
|
# Install Nodejs dependencies
|
|
pushd "$install_dir"
|
|
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install
|
|
popd
|
|
|
|
#=================================================
|
|
# 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="Mongo Express to easily administer your Mongo databases" --log="/var/log/$app/$app.log"
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
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"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|