mirror of
https://github.com/YunoHost-Apps/rocketchat_ynh.git
synced 2024-09-03 20:16:25 +02:00
More fixes
This commit is contained in:
parent
dfa72bfa00
commit
5774dfafcb
6 changed files with 79 additions and 61 deletions
|
@ -29,14 +29,14 @@ MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-5.0.asc"
|
|||
# example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")"
|
||||
#
|
||||
# usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval]
|
||||
# | arg: -u, --user= - The user name to connect as
|
||||
# | arg: -p, --password= - The user password
|
||||
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
|
||||
# | arg: -d, --database= - The database to connect to
|
||||
# | arg: -h, --host= - The host to connect to
|
||||
# | arg: -P, --port= - The port to connect to
|
||||
# | arg: -c, --command= - The command to evaluate
|
||||
# | arg: -e, --eval - Evaluate instead of execute the command.
|
||||
# | arg: -u, --user= - The user name to connect as
|
||||
# | arg: -p, --password= - The user password
|
||||
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
|
||||
# | arg: -d, --database= - The database to connect to
|
||||
# | arg: -h, --host= - The host to connect to
|
||||
# | arg: -P, --port= - The port to connect to
|
||||
# | arg: -c, --command= - The command to evaluate
|
||||
# | arg: -e, --eval - Evaluate instead of execute the command.
|
||||
#
|
||||
#
|
||||
ynh_mongo_exec() {
|
||||
|
@ -172,9 +172,9 @@ ynh_mongo_dump_db() {
|
|||
# [internal]
|
||||
#
|
||||
# usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name
|
||||
# | arg: -u, --db_user= - The user name to create
|
||||
# | arg: -p, --db_pwd= - The password to identify user by
|
||||
# | arg: -n, --db_name= - Name of the database to grant privilegies
|
||||
# | arg: -u, --db_user= - The user name to create
|
||||
# | arg: -p, --db_pwd= - The password to identify user by
|
||||
# | arg: -n, --db_name= - Name of the database to grant privilegies
|
||||
#
|
||||
#
|
||||
ynh_mongo_create_user() {
|
||||
|
@ -241,8 +241,8 @@ ynh_mongo_restore_db() {
|
|||
# [internal]
|
||||
#
|
||||
# usage: ynh_mongo_drop_user --db_user=user --db_name=name
|
||||
# | arg: -u, --db_user= - The user to drop
|
||||
# | arg: -n, --db_name= - Name of the database
|
||||
# | arg: -u, --db_user= - The user to drop
|
||||
# | arg: -n, --db_name= - Name of the database
|
||||
#
|
||||
#
|
||||
ynh_mongo_drop_user() {
|
||||
|
@ -260,9 +260,9 @@ ynh_mongo_drop_user() {
|
|||
# Create a database, an user and its password. Then store the password in the app's config
|
||||
#
|
||||
# usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd]
|
||||
# | arg: -u, --db_user= - Owner of the database
|
||||
# | arg: -n, --db_name= - Name of the database
|
||||
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
|
||||
# | arg: -u, --db_user= - Owner of the database
|
||||
# | arg: -n, --db_name= - Name of the database
|
||||
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
|
||||
#
|
||||
# After executing this helper, the password of the created database will be available in $db_pwd
|
||||
# It will also be stored as "mongopwd" into the app settings.
|
||||
|
@ -292,8 +292,8 @@ ynh_mongo_setup_db() {
|
|||
# Remove a database if it exists, and the associated user
|
||||
#
|
||||
# usage: ynh_mongo_remove_db --db_user=user --db_name=name
|
||||
# | arg: -u, --db_user= - Owner of the database
|
||||
# | arg: -n, --db_name= - Name of the database
|
||||
# | arg: -u, --db_user= - Owner of the database
|
||||
# | arg: -n, --db_name= - Name of the database
|
||||
#
|
||||
#
|
||||
ynh_mongo_remove_db() {
|
||||
|
@ -348,6 +348,7 @@ ynh_remove_mongo() {
|
|||
mongodb_servicename=$MONGO_CE_SERVICENAME
|
||||
# Remove the mongodb service
|
||||
yunohost service remove $mongodb_servicename
|
||||
# ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE
|
||||
ynh_secure_remove --file="/var/lib/mongodb"
|
||||
ynh_secure_remove --file="/var/log/mongodb"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
|
|||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -87,7 +87,7 @@ ynh_exec_warn_less ynh_install_mongo
|
|||
ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A MONGODB DATABASE
|
||||
|
@ -122,14 +122,29 @@ ynh_add_nginx_config
|
|||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# CONFIGURE MONGOD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring mongod..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG
|
||||
ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG
|
||||
|
||||
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
|
||||
ynh_systemd_action --service_name=$mongodb_servicename --action=restart
|
||||
|
||||
sleep 10
|
||||
|
||||
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
|
||||
|
||||
#==============================================
|
||||
# INSTALL ROCKETCHAT
|
||||
#==============================================
|
||||
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20
|
||||
|
||||
pushd $final_path/programs/server
|
||||
ynh_use_nodejs
|
||||
ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --unsafe-perm 2>/dev/null
|
||||
ynh_use_nodejs
|
||||
ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --unsafe-perm 2>/dev/null
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
@ -140,19 +155,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE MONGOD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring mongod..." --weight=1
|
||||
|
||||
sed -i "s/^# engine:/ engine: wiredTiger/" $MONGO_CE_CONFIG
|
||||
sed -i "s/^#replication:/replication:\n replSetName: rs01/" $MONGO_CE_CONFIG
|
||||
|
||||
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
|
||||
ynh_systemd_action --service_name=$mongodb_servicename --action=restart
|
||||
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -168,7 +170,7 @@ ynh_use_logrotate
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="Team collaboration communication platform"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
|
|
@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
nh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
|
@ -42,7 +42,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
|||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
ynh_remove_systemd_config --service=$mongodb_servicename
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
|
@ -57,6 +56,15 @@ ynh_remove_logrotate
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing the MongoDB database..."
|
||||
|
||||
ynh_mongo_exec --command="printjson(rs.remove(localhost))" --eval
|
||||
ynh_replace_string --match_string="engine: wiredTiger" --replace_string="# engine:" --target_file=$MONGO_CE_CONFIG
|
||||
ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file=$MONGO_CE_CONFIG
|
||||
ynh_replace_string --match_string=" replSetName: rs01" --replace_string="" --target_file=$MONGO_CE_CONFIG
|
||||
|
||||
ynh_systemd_action --service_name=$mongodb_servicename --action=restart
|
||||
|
||||
sleep 10
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
|
@ -86,9 +94,9 @@ ynh_remove_nginx_config
|
|||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_mongo
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_mongo
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -38,7 +38,8 @@ db_user=$db_name
|
|||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -48,7 +49,7 @@ test ! -d $final_path || ynh_die --message="There is already a directory: $final
|
|||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
|
@ -94,14 +95,16 @@ ynh_mongo_restore_db --database="$db_name" < ./dump.bson
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring mongod..." --weight=3
|
||||
|
||||
sed -i "s/^# engine:/ engine: wiredTiger/" $MONGO_CE_CONFIG
|
||||
sed -i "s/^#replication:/replication:\n replSetName: rs01/" $MONGO_CE_CONFIG
|
||||
ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG
|
||||
ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG
|
||||
|
||||
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
|
||||
ynh_systemd_action --service_name=$mongodb_servicename --action=restart
|
||||
|
||||
sleep 10
|
||||
|
||||
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
@ -122,7 +125,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="Team collaboration communication platform"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
|
|
@ -119,14 +119,29 @@ ynh_add_nginx_config
|
|||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# CONFIGURE MONGOD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring mongod..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG
|
||||
ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG
|
||||
|
||||
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
|
||||
ynh_systemd_action --service_name=$mongodb_servicename --action=restart
|
||||
|
||||
sleep 10
|
||||
|
||||
ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval
|
||||
|
||||
#==============================================
|
||||
# INSTALL ROCKETCHAT
|
||||
#==============================================
|
||||
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20
|
||||
|
||||
pushd $final_path/programs/server
|
||||
ynh_use_nodejs
|
||||
ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm 2>/dev/null
|
||||
ynh_use_nodejs
|
||||
ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm 2>/dev/null
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
@ -137,19 +152,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE MONGOD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring mongod..." --weight=1
|
||||
|
||||
sed -i "s/^# engine:/ engine: wiredTiger/" $MONGO_CE_CONFIG
|
||||
sed -i "s/^#replication:/replication:\n replSetName: rs01/" $MONGO_CE_CONFIG
|
||||
|
||||
ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet
|
||||
ynh_systemd_action --service_name=$mongodb_servicename --action=restart
|
||||
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -165,7 +167,7 @@ ynh_use_logrotate --non-append
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="Team collaboration communication platform"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
|
Loading…
Reference in a new issue