mirror of
https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh.git
synced 2024-09-03 19:46:01 +02:00
Finish refactor updater.sh, fix some install missing values and clean remove script
This commit is contained in:
parent
b7c0120eab
commit
9377a553a2
3 changed files with 13 additions and 37 deletions
25
.github/workflows/updater.sh
vendored
25
.github/workflows/updater.sh
vendored
|
@ -14,8 +14,8 @@
|
|||
#=================================================
|
||||
|
||||
# Fetching information
|
||||
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
|
||||
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
|
||||
current_version=$(yq ".version" manifest.toml | cut -d '~' -f 1 -)
|
||||
repo=$(yq ".upstream.code" manifest.toml | sed 's/https:\/\/github.com\///')
|
||||
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
|
||||
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
|
||||
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
|
||||
|
@ -31,9 +31,9 @@ fi
|
|||
# Setting up the environment variables
|
||||
echo "Current version: $current_version"
|
||||
echo "Latest release from upstream: $version"
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
echo "VERSION=$version" >> "$GITHUB_ENV"
|
||||
# For the time being, let's assume the script will fail
|
||||
echo "PROCEED=false" >> $GITHUB_ENV
|
||||
echo "PROCEED=false" >> "$GITHUB_ENV"
|
||||
|
||||
# Proceed only if the retrieved version is greater than the current one
|
||||
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
||||
|
@ -91,15 +91,8 @@ curl --silent -4 -L $tarball -o "$tempdir/$version"
|
|||
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
|
||||
|
||||
# Rewrite source file
|
||||
cat <<EOT > conf/$src.src
|
||||
SOURCE_URL=$asset_url
|
||||
SOURCE_SUM=$checksum
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
||||
EOT
|
||||
echo "... conf/$src.src updated"
|
||||
sed -i "s|$src.url.*|src.url = \"$asset_url\"|g" manifest.toml
|
||||
sed -i "s|$src.sha256.*|$src.sha256 = \"$checksum\"|g" manifest.toml
|
||||
|
||||
else
|
||||
echo "... asset ignored"
|
||||
|
@ -107,6 +100,8 @@ fi
|
|||
|
||||
done
|
||||
|
||||
echo "manifest.toml assets updated"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPDATE STEPS
|
||||
#=================================================
|
||||
|
@ -148,7 +143,7 @@ yq -i '.bridge.encryption.require = "__ENCRYPTION_REQUIRE__"' $configFilePath
|
|||
yq -i 'with(.bridge.permissions ; . = { "__LISTRELAY__": "relay", "__LISTUSER__": "user", "__LISTADMIN__": "admin" } | ... style="double")' $configFilePath
|
||||
yq -i '.bridge.relay.enabled = "__ENABLE_RELAYBOT__"' $configFilePath
|
||||
yq -i '.bridge.relay.admin_only = "__ADMIN_ONLY__"' $configFilePath
|
||||
yq -i '.logging.writers.filename = "/var/log/__APP__/__APP__.log"' $configFilePath
|
||||
yq -i '.logging.writers[1].filename = "/var/log/__APP__/__APP__.log"' $configFilePath
|
||||
yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath
|
||||
|
||||
#=================================================
|
||||
|
@ -156,7 +151,7 @@ yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath
|
|||
#=================================================
|
||||
|
||||
# Replace new version in manifest
|
||||
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
|
||||
sed -i "s|version.*|version = \"$version~ynh1\"|g" manifest.toml
|
||||
|
||||
# Delete temporary directory
|
||||
rm -rf $tempdir
|
||||
|
|
|
@ -17,9 +17,11 @@ ynh_clean_setup () {
|
|||
true
|
||||
}
|
||||
|
||||
# Retrieve some values from selected Synapse instance
|
||||
# Retrieve some values from selected Synapse instance and store them
|
||||
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
|
||||
domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
||||
ynh_app_setting_set --app=$app --key=server_name --value=$server_name
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
|
||||
# This is needed to convert the value from the manifest to a valid value for the config.yaml file.
|
||||
|
|
|
@ -49,27 +49,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
|
|||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4
|
||||
|
||||
if ynh_psql_user_exists --user="$app"; then
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$app\";"
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$app\";"
|
||||
fi
|
||||
|
||||
if ynh_psql_user_exists --user="$bot_synapse_db_user"; then
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$bot_synapse_db_user\";"
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$bot_synapse_db_user\";"
|
||||
fi
|
||||
|
||||
if ynh_psql_user_exists --user="$botname"; then
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$botname\";"
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$botname\";"
|
||||
fi
|
||||
#yunohost app action run $synapse_instance drop_user -a username=$botname
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue