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
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path)
admin=$(ynh_app_setting_get --app="$app" --key=admin)
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
admin_token=$(ynh_app_setting_get --app=$app --key=admin_token)
rocket_port=$(ynh_app_setting_get --app=$app --key=rocket_port)
websocket_port=$(ynh_app_setting_get --app=$app --key=websocket_port)
admin_token=$(ynh_app_setting_get --app="$app" --key=admin_token)
rocket_port=$(ynh_app_setting_get --app="$app" --key=rocket_port)
websocket_port=$(ynh_app_setting_get --app="$app" --key=websocket_port)
#=================================================
# CHECK VERSION
@ -39,17 +39,17 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Fix is_public as a boolean value
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
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
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
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
#=================================================
@ -74,7 +74,7 @@ ynh_abort_if_errors
#=================================================
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
@ -104,7 +104,7 @@ ynh_add_nginx_config "websocket_port rocket_port"
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies
ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# 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
# 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
@ -122,24 +122,24 @@ ynh_system_user_create --username=$app --home_dir=$final_path
ynh_script_progression --message="Making upgrade..." --weight=760
# Set right permissions
chown -R "$app":"$app" $final_path
chown -R "$app":"$app" "$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
# Install rustup with the toolchain needed by bitwarden_rs
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=$(cat build/rust-toolchain)'
popd
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)'
popd || exit
export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin"
# Compile bitwarden_rs
pushd $final_path/build
sudo -u "$app" env PATH=$PATH cargo build --features sqlite --release
popd
pushd "$final_path"/build || exit
sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release
popd || exit
# 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
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
chown -R "$app":"$app" $final_path
chown -R "$app":"$app" "$final_path"
mkdir -p "/var/log/$app"
chown -R "$app":"$app" /var/log/$app
chown -R "$app":"$app" /var/log/"$app"
#=================================================
# SETUP SSOWAT
@ -214,7 +214,7 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
if [ $is_public -eq 1 ]
then
# 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
#=================================================
@ -222,9 +222,9 @@ fi
#=================================================
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"
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="start" --log_path="systemd" --line_match="Rocket has launched from"
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"
fi
#=================================================