1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libremdb_ynh.git synced 2024-09-03 19:36:22 +02:00

Merge pull request #6 from YunoHost-Apps/ci-auto-update-v3.0.0

Upgrade to version 3.0.0
This commit is contained in:
Sebastian Gumprich 2023-04-19 13:24:08 +02:00 committed by GitHub
commit 06145e4e5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 122 additions and 34 deletions

View file

@ -21,7 +21,7 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# 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 "'"))
assets="https://github.com/$repo/archive/refs/tags/$version.tar.gz"
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
@ -44,7 +44,7 @@ if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
#exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
@ -54,23 +54,8 @@ echo "${#assets[@]} available asset(s)"
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"libremdb")
src="app"
;;
*)
src=""
;;
esac
asset_url=$assets
src="app"
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
@ -99,8 +84,9 @@ SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=false
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT
echo "... conf/$src.src updated"
@ -108,8 +94,6 @@ else
echo "... asset ignored"
fi
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================

View file

@ -45,5 +45,5 @@ jobs:
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
Changelog: https://github.com/invoiceninja/invoiceninja/releases/tag/v${{ env.VERSION }}
Changelog: https://github.com/zyachel/libremdb/releases/tag/v${{ env.VERSION }}
draft: false

View file

@ -27,7 +27,7 @@ A free & open source IMDb front-end.
**Shipped version:** 2.2.2~ynh1
**Shipped version:** 3.0.0~ynh1
**Demo:** https://libremdb.iket.me/about

View file

@ -27,7 +27,7 @@ A free & open source IMDb front-end.
**Version incluse :** 2.2.2~ynh1
**Version incluse :** 3.0.0~ynh1
**Démo :** https://libremdb.iket.me/about

View file

@ -6,7 +6,7 @@
port="666"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
@ -15,7 +15,7 @@
#upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=1
port_already_use=0
port_already_use=1 (8095)
change_url=1
;;; Options
Email=

View file

@ -23,6 +23,14 @@ NEXT_TELEMETRY_DISABLED=1
### 3. REDIS CONFIG(optional if you don't need redis)
################################################################################
## if you want to use redis to speed up the media proxy, set this to true
# USE_REDIS=true
USE_REDIS=true
## for docker, just set the domain to the container name, default is 'libremdb_redis'
REDIS_URL=localhost:6379
################################################################################
### 4. INSTANCE META FIELDS(not required but good to have)
################################################################################
## example: 'https://iket.me'.
NEXT_PUBLIC_INSTANCE_MAIN_URL=https://__DOMAIN__
## eg: 'zyachel'
NEXT_PUBLIC_INSTANCE_NAME=__DOMAIN__

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/zyachel/libremdb/archive/refs/tags/v2.2.2.tar.gz
SOURCE_SUM=0f58b9d9f1a0a9787352c3c358806d3729db611888ae23e166e870cb049ca151
SOURCE_URL=https://github.com/zyachel/libremdb/archive/refs/tags/v3.0.0.tar.gz
SOURCE_SUM=8519c55ed0f74189270c3d09e85f2509301bb66e3749503e4b015c90142a1a8a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -6,7 +6,7 @@
"en": "Free & open source IMDb front-end",
"fr": "Frontal IMDb gratuit et open source"
},
"version": "2.2.2~ynh1",
"version": "3.0.0~ynh1",
"url": "https://libremdb.iket.me/",
"upstream": {
"license": "AGPL-3.0",
@ -24,7 +24,8 @@
},
"multi_instance": true,
"services": [
"nginx"
"nginx",
"redis-server"
],
"arguments": {
"install": [

View file

@ -28,8 +28,9 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP

View file

@ -100,6 +100,18 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# CHANGE APP CONFIGURATION
#=================================================
ynh_script_progression --message="Changing app configuration file..." --weight=1
domain="$old_domain"
ynh_add_config --template="../conf/.env.local.example" --destination="$final_path/.env.local"
chmod 400 "$final_path/.env.local"
chown $app:$app "$final_path/.env.local"
#=================================================
# GENERIC FINALISATION
#=================================================

View file

@ -7,6 +7,7 @@
#=================================================
source _common.sh
source ynh_redis
source /usr/share/yunohost/helpers
#=================================================
@ -24,11 +25,12 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
@ -100,6 +102,13 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CONFIGURE REDIS
#=================================================
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#=================================================
# INSTALL LIBREMDB
#=================================================

View file

@ -7,6 +7,7 @@
#=================================================
source _common.sh
source ynh_redis
source /usr/share/yunohost/helpers
#=================================================
@ -19,6 +20,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#=================================================
# STANDARD REMOVE
@ -57,6 +59,13 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE THE REDIS DATABASE
#=================================================
ynh_script_progression --message="Removing the redis database..."
ynh_redis_remove_db "$redis_db"
#=================================================
# REMOVE DEPENDENCIES
#=================================================

View file

@ -29,6 +29,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)

View file

@ -7,6 +7,7 @@
#=================================================
source _common.sh
source ynh_redis
source /usr/share/yunohost/helpers
#=================================================
@ -17,8 +18,10 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#=================================================
# CHECK VERSION
@ -49,6 +52,17 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If redis_db doesn't exist, create it
if [ -z "$redis_db" ]; then
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -84,6 +98,16 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
# Install Yarn
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/.env.local.example" --destination="$final_path/.env.local"
chmod 400 "$final_path/.env.local"
chown $app:$app "$final_path/.env.local"
#=================================================
# NGINX CONFIGURATION
#=================================================

39
scripts/ynh_redis Normal file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# get the first available redis database
#
# usage: ynh_redis_get_free_db
# | returns: the database number to use
ynh_redis_get_free_db() {
local result max db
result=$(redis-cli INFO keyspace)
# get the num
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
db=0
# default Debian setting is 15 databases
for i in $(seq 0 "$max")
do
if ! echo "$result" | grep -q "db$i"
then
db=$i
break 1
fi
db=-1
done
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
echo "$db"
}
# Create a master password and set up global settings
# Please always call this script in install and restore scripts
#
# usage: ynh_redis_remove_db database
# | arg: database - the database to erase
ynh_redis_remove_db() {
local db=$1
redis-cli -n "$db" flushall
}