diff --git a/scripts/_common.sh b/scripts/_common.sh index f983ca9..22b933d 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,6 +10,8 @@ install_sources() { fi mkdir -p $final_path + chown $synapse_user:root -R $final_path + chown $synapse_user:root -R $data_path if [ -n "$(uname -m | grep arm)" ] then @@ -28,6 +30,19 @@ install_sources() { fi done else + # Install rustup is not already installed + # We need this to be able to install cryptgraphy + export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" + if [ -e $final_path/.rustup ]; then + sudo -u "$synapse_user" env PATH=$PATH rustup update + else + sudo -u "$synapse_user" bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=stable' + mv $data_path/.cargo $final_path/ + mv $data_path/.rustup $final_path/ + ln -s $final_path/.cargo $data_path/.cargo + ln -s $final_path/.rustup $data_path/.rustup + fi + # Install virtualenv if it don't exist test -e $final_path/bin/python3 || python3 -m venv $final_path @@ -39,8 +54,10 @@ install_sources() { source $final_path/bin/activate set -u; pip3 install --upgrade setuptools wheel + chown $synapse_user:root -R $final_path + sudo -u $synapse_user env PATH=$PATH pip3 install --upgrade 'cryptography>=3.3' pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml jinja2 - pip3 install --upgrade 'Twisted>=20.3.0' 'cryptography>=3.3' matrix-synapse==$upstream_version matrix-synapse-ldap3 + pip3 install --upgrade 'Twisted>=20.3.0' matrix-synapse==$upstream_version matrix-synapse-ldap3 # This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does set +u; diff --git a/scripts/restore b/scripts/restore index 9b27ca4..46bcb99 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,6 +72,16 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=70 # For any update do it in all files ynh_install_app_dependencies $dependances +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$synapse_user --home_dir=$data_path +adduser $synapse_user ssl-cert +adduser turnserver ssl-cert + #================================================= # RESTORE ALL CONFIG AND DATA #================================================= @@ -92,18 +102,6 @@ install_sources ynh_script_progression --message="Reload fail2ban..." --weight=6 ynh_systemd_action --action=restart --service_name=fail2ban -#================================================= -# SPECIFIC RESTORATION -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$synapse_user --home_dir=$data_path -adduser $synapse_user ssl-cert -adduser turnserver ssl-cert - #================================================= # RESTORE THE POSTGRESQL DATABASE #=================================================