1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/vaultwarden_ynh.git synced 2024-09-03 18:26:31 +02:00

Update upgrade

This commit is contained in:
liberodark 2019-12-19 17:34:40 +01:00 committed by GitHub
parent cb71d3323d
commit 65f9d41e73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,15 +16,15 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app="$app" --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app="$app" --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public) is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
admin_token=$(ynh_app_setting_get --app=$app --key=admin_token) admin_token=$(ynh_app_setting_get --app="$app" --key=admin_token)
rocket_port=$(ynh_app_setting_get --app=$app --key=rocket_port) rocket_port=$(ynh_app_setting_get --app="$app" --key=rocket_port)
websocket_port=$(ynh_app_setting_get --app=$app --key=websocket_port) websocket_port=$(ynh_app_setting_get --app="$app" --key=websocket_port)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -39,17 +39,17 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1 ynh_app_setting_set --app="$app" --key=is_public --value=1
is_public=1 is_public=1
elif [ "$is_public" = "No" ]; then elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0 ynh_app_setting_set --app="$app" --key=is_public --value=0
is_public=0 is_public=0
fi fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z "$final_path" ]; then if [ -z "$final_path" ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
fi fi
#================================================= #=================================================
@ -74,7 +74,7 @@ ynh_abort_if_errors
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Bitwarden Server" ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped Bitwarden Server"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -104,7 +104,7 @@ ynh_add_nginx_config "websocket_port rocket_port"
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -112,7 +112,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing) # Create a 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"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -122,24 +122,24 @@ ynh_system_user_create --username=$app --home_dir=$final_path
ynh_script_progression --message="Making upgrade..." --weight=760 ynh_script_progression --message="Making upgrade..." --weight=760
# Set right permissions # Set right permissions
chown -R "$app":"$app" $final_path chown -R "$app":"$app" "$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
# Install rustup with the toolchain needed by bitwarden_rs # Install rustup with the toolchain needed by bitwarden_rs
pushd $final_path pushd "$final_path" || exit
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=$(cat build/rust-toolchain)' 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=$(cat build/rust-toolchain)'
popd popd || exit
export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin"
# Compile bitwarden_rs # Compile bitwarden_rs
pushd $final_path/build pushd "$final_path"/build || exit
sudo -u "$app" env PATH=$PATH cargo build --features sqlite --release sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release
popd popd || exit
# Install bitwarden_rs # Install bitwarden_rs
cp -a $final_path/build/target/release/. $final_path/live/. cp -a "$final_path"/build/target/release/. "$final_path"/live/.
# Remove build files and rustup # Remove build files and rustup
ynh_secure_remove --file="$final_path/build" ynh_secure_remove --file="$final_path/build"
@ -201,9 +201,9 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Usern
#================================================= #=================================================
# Set permissions on app files # Set permissions on app files
chown -R "$app":"$app" $final_path chown -R "$app":"$app" "$final_path"
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R "$app":"$app" /var/log/$app chown -R "$app":"$app" /var/log/"$app"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
@ -214,7 +214,7 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway # unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
fi fi
#================================================= #=================================================
@ -222,9 +222,9 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Rocket has launched from"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Rocket has launched from" ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" --line_match="Rocket has launched from"
fi fi
#================================================= #=================================================