mirror of
https://github.com/YunoHost-Apps/plume_ynh.git
synced 2024-09-03 20:15:54 +02:00
Clean up
This commit is contained in:
parent
8e2027b5ee
commit
cae680cf44
6 changed files with 62 additions and 55 deletions
|
@ -2,7 +2,7 @@
|
|||
# (replace USER, PASSWORD, PORT and DATABASE_NAME with your values)
|
||||
#
|
||||
# If you are using SQlite, use the path of the database file (`plume.db` for instance)
|
||||
DATABASE_URL=postgres://__DB_USER__:__PSQLPWD__@localhost:5432/__DBNAME__
|
||||
DATABASE_URL=postgres://__DB_NAME__:__DB_PWD__@localhost:5432/__DB_NAME__
|
||||
|
||||
# For PostgreSQL: migrations/postgres
|
||||
# For SQlite: migrations/sqlite
|
||||
|
@ -16,4 +16,4 @@ ROCKET_ADDRESS=127.0.0.1
|
|||
|
||||
# Secret key used for private cookies and CSRF protection
|
||||
# You can generate one with `openssl rand -base64 32`
|
||||
ROCKET_SECRET_KEY=__KEY__
|
||||
ROCKET_SECRET_KEY=__SECRET_KEY__
|
||||
|
|
|
@ -29,7 +29,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
|
|
|
@ -33,7 +33,7 @@ password=$YNH_APP_ARG_PASSWORD
|
|||
instance_name=$YNH_APP_ARG_NAME
|
||||
registration=$YNH_APP_ARG_REGISTRATION
|
||||
admin_email=$(ynh_user_get_info $admin 'mail')
|
||||
random_key=$(openssl rand -base64 32)
|
||||
secret_key=$(openssl rand -base64 32)
|
||||
|
||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
|
@ -75,7 +75,7 @@ ynh_app_setting_set $app is_public $is_public
|
|||
ynh_app_setting_set $app instance $instance_name
|
||||
ynh_app_setting_set $app registration $registration
|
||||
ynh_app_setting_set $app admin_email $admin_email
|
||||
ynh_app_setting_set $app random_key $random_key
|
||||
ynh_app_setting_set $app secret_key $secret_key
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -121,11 +121,11 @@ ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git
|
|||
ynh_psql_test_if_first_run
|
||||
db_name="$app"
|
||||
db_pwd=$(ynh_string_random 30)
|
||||
ynh_app_setting_set "$app" psql_db "$db_name"
|
||||
ynh_app_setting_set "$app" psqlpwd "$db_pwd"
|
||||
ynh_psql_create_user "$app" "$db_pwd"
|
||||
ynh_app_setting_set "$app" db_name "$db_name"
|
||||
ynh_app_setting_set "$app" db_pwd "$db_pwd"
|
||||
ynh_psql_create_user "$db_name" "$db_pwd"
|
||||
ynh_psql_execute_as_root \
|
||||
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
|
||||
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $db_name;"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -143,7 +143,6 @@ git clone https://github.com/Plume-org/Plume.git "$final_path/$app"
|
|||
# Create the media directory, where uploads will be stored
|
||||
(cd $final_path && mkdir media )
|
||||
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -192,12 +191,11 @@ chown -R "$app":"$app" "/var/log/$app"
|
|||
#=================================================
|
||||
# setup application config
|
||||
sudo cp "../conf/.env" "$final_path/$app/.env"
|
||||
ynh_replace_string "__DBNAME__" "$db_name" "$final_path/$app/.env"
|
||||
ynh_replace_string "__PSQLPWD__" "$db_pwd" "$final_path/$app/.env"
|
||||
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/$app/.env"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/.env"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/.env"
|
||||
ynh_replace_string "__PORT__" "$port" "$final_path/$app/.env"
|
||||
ynh_replace_string "__DB_USER__" "$app" "$final_path/$app/.env"
|
||||
ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/.env"
|
||||
ynh_replace_string "__SECRET_KEY__" "$secret_key" "$final_path/$app/.env"
|
||||
|
||||
#=================================================
|
||||
# MAKE SETUP
|
||||
|
@ -206,29 +204,33 @@ ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/.env"
|
|||
# Set right permissions
|
||||
chown -R "$app":"$app" $final_path
|
||||
|
||||
# App settings
|
||||
( cd $final_path && sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly' )
|
||||
PATH="$PATH:$final_path/.cargo/bin"
|
||||
export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin"
|
||||
export FEATURES=postgres
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/cargo install diesel_cli --no-default-features --features postgres --version '=1.3.0' )
|
||||
( cd $final_path/$app && diesel migration run )
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/cargo install --no-default-features --features postgres )
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/cargo install --no-default-features --features postgres --path plume-cli )
|
||||
# Install
|
||||
pushd $final_path
|
||||
sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly'
|
||||
popd
|
||||
|
||||
# Add new instance
|
||||
if [ $registration -eq 1 ]
|
||||
then
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm instance new --domain "$domain" --name "$instance_name" -l 'CC-BY' )
|
||||
else
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm instance new --private --domain "$domain" --name "$instance_name" -l 'CC-BY' )
|
||||
fi
|
||||
export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin"
|
||||
|
||||
# Add admin user
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm users new --admin -n "$admin" -N "$admin" --email "$admin_email" --password "$password" )
|
||||
pushd $final_path/$app
|
||||
sudo -u "$app" env PATH=$PATH cargo install diesel_cli --no-default-features --features postgres --version '=1.3.0'
|
||||
sudo -u "$app" env PATH=$PATH diesel migration run
|
||||
sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres
|
||||
sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres --path plume-cli
|
||||
|
||||
# Initialise search index
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm search init -p $final_path/$app )
|
||||
# Add new instance
|
||||
if [ $registration -eq 1 ]
|
||||
then
|
||||
sudo -u "$app" env PATH=$PATH plm instance new --domain "$domain" --name "$instance_name" -l 'CC-BY'
|
||||
else
|
||||
sudo -u "$app" env PATH=$PATH plm instance new --private --domain "$domain" --name "$instance_name" -l 'CC-BY'
|
||||
fi
|
||||
|
||||
# Add admin user
|
||||
sudo -u "$app" env PATH=$PATH plm users new --admin -n "$admin" -N "$admin" --email "$admin_email" --password "$password"
|
||||
|
||||
# Initialise search index
|
||||
sudo -u "$app" env PATH=$PATH plm search init -p $final_path/$app
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -308,7 +310,7 @@ ynh_store_file_checksum "$final_path/$app/.env"
|
|||
### that really need such authorization.
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app: $final_path
|
||||
# chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
|
|
|
@ -18,8 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||
db_user=$db_name
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
|
@ -42,6 +41,13 @@ fi
|
|||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db "$db_name" "$app"
|
||||
|
||||
#=================================================
|
||||
|
||||
# REMOVE DEPENDENCIES
|
||||
|
@ -49,21 +55,17 @@ ynh_remove_systemd_config
|
|||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
export PATH="$PATH:$final_path/.cargo/bin:/var/$app/.local/bin:/usr/local/sbin"
|
||||
export FEATURES=postgres
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/cargo uninstall diesel_cli )
|
||||
|
||||
export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin"
|
||||
|
||||
pushd $final_path/$app
|
||||
sudo -u "$app" env PATH=$PATH cargo uninstall diesel_cli
|
||||
popd
|
||||
|
||||
if [ -d "/usr/local/lib/rustlib" ]; then
|
||||
sudo /usr/local/lib/rustlib/uninstall.sh
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db "$db_name" "$app"
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
|
|
@ -31,8 +31,8 @@ domain=$(ynh_app_setting_get $app domain)
|
|||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
port=$(ynh_app_setting_get "$app" port)
|
||||
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
db_pwd=$(ynh_app_setting_get "$app" db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -63,9 +63,9 @@ ynh_restore_file "$final_path"
|
|||
|
||||
ynh_install_app_dependencies postgresql postgresql-contrib
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_create_user "$app" "$db_pwd"
|
||||
ynh_psql_create_user "$db_name" "$db_pwd"
|
||||
ynh_psql_execute_as_root \
|
||||
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
|
||||
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $db_name;"
|
||||
ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
||||
|
||||
#=================================================
|
||||
|
@ -80,7 +80,7 @@ ynh_system_user_create "$app" "$final_path"
|
|||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app: $final_path
|
||||
chown -R "$app":"$app" $final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
|
@ -107,8 +107,11 @@ systemctl enable $app.service
|
|||
systemctl daemon-reload
|
||||
|
||||
#Fix Your search index is locked.
|
||||
export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin"
|
||||
|
||||
( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm search unlock )
|
||||
pushd $final_path/$app
|
||||
sudo -u "$app" env PATH=$PATH plm search unlock
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
|
|
|
@ -22,9 +22,9 @@ admin=$(ynh_app_setting_get $app admin)
|
|||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
db_name=$(ynh_app_setting_get "$app" psql_db)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
admin_email=$(ynh_app_setting_get "$app" admin_email)
|
||||
random_key=$(ynh_app_setting_get "$app" random_key)
|
||||
secret_key=$(ynh_app_setting_get "$app" secret_key)
|
||||
name=$(ynh_app_setting_get "$app" name)
|
||||
port=$(ynh_app_setting_get "$app" port)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue