1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/photoview_ynh.git synced 2024-09-03 20:05:55 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:27:58 +02:00 committed by GitHub
commit 343d48fe23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 121 additions and 136 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store

View file

@ -20,7 +20,8 @@ code = "https://github.com/photoview/photoview"
fund = "https://github.com/sponsors/viktorstrate"
[integration]
yunohost = ">= 11.2.12"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
ldap = false

View file

@ -1,26 +1,21 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
go_version=1.20
node_version=16
#=================================================
# PERSONAL HELPERS
#=================================================
function set_go_vars {
ynh_use_go
export GOPATH="$install_dir/build/go"
export GOCACHE="$install_dir/build/.cache"
go_shims_path=$goenv_install_dir/shims
go_path_full="$go_shims_path":"$(sudo -u $app bash -c 'echo $PATH')"
heif_lib_path="$install_dir/local/lib":"$(sudo -u $app bash -c 'echo $LIBRARY_PATH')"
heif_ld_lib_path="$install_dir/local/lib":"$(sudo -u $app bash -c 'echo $LD_LIBRARY_PATH')"
go_path_full="$go_shims_path":"$(ynh_exec_as_app bash -c 'echo $PATH')"
heif_lib_path="$install_dir/local/lib":"$(ynh_exec_as_app bash -c 'echo $LIBRARY_PATH')"
heif_ld_lib_path="$install_dir/local/lib":"$(ynh_exec_as_app bash -c 'echo $LD_LIBRARY_PATH')"
heif_cgo_cflags="-I$install_dir/local/include"
}
@ -29,13 +24,13 @@ function build_libheif {
export GOCACHE="$install_dir/build/.cache"
pushd "$install_dir/libheif" || ynh_die
ynh_exec_as "$app" mkdir build
ynh_exec_as_app mkdir build
pushd build
ynh_exec_and_print_stderr_only_if_error ynh_exec_as "$app" \
ynh_exec_and_print_stderr_only_if_error ynh_exec_as_app \
cmake --preset=release -DCMAKE_INSTALL_PREFIX="$install_dir/local" -DWITH_GDK_PIXBUF=OFF -G Ninja ..
ynh_exec_and_print_stderr_only_if_error ynh_exec_as "$app" \
ynh_exec_and_print_stderr_only_if_error ynh_exec_as_app \
ninja
ynh_exec_and_print_stderr_only_if_error ynh_exec_as "$app" \
ynh_exec_and_print_stderr_only_if_error ynh_exec_as_app \
ninja install
popd
popd || ynh_die
@ -56,12 +51,12 @@ function build_api {
pushd "$install_dir/sources/api" || ynh_die
set +e
for i in {1..5}; do
ynh_exec_as "$app" env "${gobuild_env[@]}" go mod download 2>&1 && break
ynh_exec_as_app "${gobuild_env[@]}" go mod download 2>&1 && break
sleep 5
done
set -e
ynh_exec_as "$app" env "${gobuild_env[@]}" go install github.com/mattn/go-sqlite3 github.com/Kagami/go-face 2>&1
ynh_exec_as "$app" env "${gobuild_env[@]}" go build -o photoview . 2>&1
ynh_exec_as_app "${gobuild_env[@]}" go install github.com/mattn/go-sqlite3 github.com/Kagami/go-face 2>&1
ynh_exec_as_app "${gobuild_env[@]}" go build -o photoview . 2>&1
popd || ynh_die
cp -T "$install_dir/sources/api/photoview" "$install_dir/output/photoview"
@ -69,35 +64,26 @@ function build_api {
}
function build_ui {
ynh_use_nodejs
pushd "$install_dir/sources/ui" || ynh_die
ynh_replace_string -m "cd .. && " -r "" -f "package.json"
# chown -R "$app:$app" $install_dir
ynh_exec_as "$app" touch ".yarnrc"
ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" import 2>&1
# ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" add husky 2>&1
ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" install --production 2>&1
ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" add graphql --production --ignore-engines 2>&1
ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" run build 2>&1
# ynh_exec_as "$app" env "$ynh_node_load_PATH" NODE_ENV=production "$ynh_npm" install
# ynh_exec_as "$app" env "$ynh_node_load_PATH" NODE_ENV=production "$ynh_npm" run build
ynh_replace -m "cd .. && " -r "" -f "package.json"
# #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" $install_dir
ynh_exec_as_app touch ".yarnrc"
ynh_exec_as_app node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" import 2>&1
# ynh_exec_as_app node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" add husky 2>&1
ynh_exec_as_app node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" install --production 2>&1
ynh_exec_as_app node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" add graphql --production --ignore-engines 2>&1
ynh_exec_as_app node_load_PATH" yarn --cache-folder "./yarn-cache" --use-yarnrc ".yarnrc" run build 2>&1
# ynh_exec_as_app node_load_PATH" NODE_ENV=production npm install
# ynh_exec_as_app node_load_PATH" NODE_ENV=production npm run build
popd || ynh_die
cp -rT "$install_dir/sources/ui/dist" "$install_dir/output/ui"
}
function cleanup_sources {
ynh_secure_remove --file="$install_dir/libheif"
ynh_secure_remove --file="$install_dir/sources"
ynh_secure_remove --file="$install_dir/go"
ynh_secure_remove --file="$install_dir/.cache/go-build"
ynh_safe_rm "$install_dir/libheif"
ynh_safe_rm "$install_dir/sources"
ynh_safe_rm "$install_dir/go"
ynh_safe_rm "$install_dir/.cache/go-build"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -8,48 +8,45 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE APP DATA DIR
#=================================================
ynh_backup --src_path="$data_dir" --is_big
ynh_backup "$data_dir"
#=================================================
# BACKUP THE SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/var/log/$app/"
ynh_backup "/var/log/$app/"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
ynh_mysql_dump_db > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -10,34 +10,34 @@ source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="stop"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_add_config --template=".env" --destination="$install_dir/output/.env"
chown "$app:$app" "$install_dir/output/.env"
ynh_config_add --template=".env" --destination="$install_dir/output/.env"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/output/.env"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -10,40 +10,40 @@ source /usr/share/yunohost/helpers
#=================================================
# INSTALL GO
#=================================================
ynh_script_progression --message="Installing Go..." --weight=10
ynh_script_progression "Installing Go..."
ynh_install_go --go_version="$go_version"
ynh_go_install
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Installing NodeJS..." --weight=10
ynh_script_progression "Installing NodeJS..."
ynh_install_nodejs --nodejs_version="$node_version"
ynh_nodejs_install
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=10
ynh_script_progression "Setting up source files..."
ynh_setup_source --dest_dir="$install_dir/sources"
ynh_setup_source --source_id=libheif --dest_dir="$install_dir/libheif"
mkdir -p "$install_dir/output/"{data,ui}
chown -R "$app:$app" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
chown -R "$app:$app" "$data_dir"
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Compiling libheif..." --weight=10
ynh_script_progression "Compiling libheif..."
build_libheif
ynh_script_progression --message="Compiling Go API..." --weight=10
ynh_script_progression "Compiling Go API..."
build_api
ynh_script_progression --message="Building static UI files..." --weight=10
ynh_script_progression "Building static UI files..."
build_ui
cleanup_sources
@ -51,36 +51,36 @@ cleanup_sources
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding $app's configuration file..."
ynh_script_progression "Adding $app's configuration file..."
ynh_add_config --template=".env" --destination="$install_dir/output/.env"
chown "$app:$app" "$install_dir/output/.env"
ynh_config_add --template=".env" --destination="$install_dir/output/.env"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/output/.env"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
yunohost service add "$app" --description="Photoview photo manager API" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
ynh_config_add_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -10,35 +10,35 @@ source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
ynh_script_progression "Removing system configurations related to $app..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_config_remove_systemd
# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
# Remove other various files specific to the app... such as :
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing Go..." --weight=5
ynh_remove_go
ynh_script_progression "Removing Go..."
ynh_go_remove
ynh_script_progression --message="Removing NodeJS..." --weight=5
ynh_remove_nodejs
ynh_script_progression "Removing NodeJS..."
ynh_nodejs_remove
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -11,37 +11,37 @@ source /usr/share/yunohost/helpers
#=================================================
# INSTALL GO
#=================================================
ynh_script_progression --message="Reinstalling Go..." --weight=10
ynh_script_progression "Reinstalling Go..."
ynh_install_go --go_version="$go_version"
ynh_go_install
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Reinstalling NodeJS..." --weight=10
ynh_script_progression "Reinstalling NodeJS..."
ynh_install_nodejs --nodejs_version="$node_version"
ynh_nodejs_install
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
ynh_restore "$install_dir"
#=================================================
# RESTORE THE APP DATA DIR
#=================================================
ynh_script_progression --message="Restoring the app data directory..." --weight=1
ynh_script_progression "Restoring the app data directory..."
ynh_restore_file --origin_path="$data_dir" --not_mandatory
ynh_restore "$data_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
ynh_mysql_db_shell < ./db.sql
#=================================================
# SPECIFIC RESTORATION
@ -52,32 +52,32 @@ set_go_vars
# RESTORE VARIOUS FILES
#=================================================
ynh_restore_file --origin_path="/var/log/$app/"
ynh_restore "/var/log/$app/"
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Photoview photo manager API" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="start"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -10,58 +10,58 @@ source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_script_progression "Ensuring downward compatibility..."
if [ ! -d "$install_dir/sources" ]; then
# Final cleanup...
ynh_secure_remove --file="$install_dir"
ynh_safe_rm "$install_dir"
mkdir -p "$install_dir"
chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
fi
#=================================================
# INSTALL GO
#=================================================
ynh_script_progression --message="Upgrading Go..." --weight=10
ynh_script_progression "Upgrading Go..."
ynh_install_go --go_version="$go_version"
ynh_go_install
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Upgrading NodeJS..." --weight=10
ynh_script_progression "Upgrading NodeJS..."
ynh_install_nodejs --nodejs_version="$node_version"
ynh_nodejs_install
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=5
ynh_script_progression "Upgrading source files..."
ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1
ynh_setup_source --source_id=libheif --dest_dir="$install_dir/libheif" --full_replace=1
ynh_setup_source --dest_dir="$install_dir/sources" --full_replace
ynh_setup_source --source_id=libheif --dest_dir="$install_dir/libheif" --full_replace
mkdir -p "$install_dir/output/"{data,ui}
chown -R "$app:$app" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
chown -R "$app:$app" "$data_dir"
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Compiling libheif..." --weight=70
ynh_script_progression "Compiling libheif..."
build_libheif
ynh_script_progression --message="Compiling Go API..." --weight=165
ynh_script_progression "Compiling Go API..."
build_api
ynh_script_progression --message="Building static UI files..." --weight=45
ynh_script_progression "Building static UI files..."
build_ui
cleanup_sources
@ -69,35 +69,35 @@ cleanup_sources
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_script_progression "Updating configuration..."
ynh_add_config --template=".env" --destination="$install_dir/output/.env"
chown "$app:$app" "$install_dir/output/.env"
ynh_config_add --template=".env" --destination="$install_dir/output/.env"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/output/.env"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
yunohost service add "$app" --description="Photoview photo manager API" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
ynh_config_add_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service="$app" --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"