mirror of
https://github.com/YunoHost-Apps/photoview_ynh.git
synced 2024-09-03 20:05:55 +02:00
Merge d249616eec
into 7a253fb80e
This commit is contained in:
commit
343d48fe23
9 changed files with 121 additions and 136 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*~
|
*~
|
||||||
*.sw[op]
|
*.sw[op]
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -20,7 +20,8 @@ code = "https://github.com/photoview/photoview"
|
||||||
fund = "https://github.com/sponsors/viktorstrate"
|
fund = "https://github.com/sponsors/viktorstrate"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2.12"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
ldap = false
|
ldap = false
|
||||||
|
|
|
@ -1,26 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
go_version=1.20
|
go_version=1.20
|
||||||
node_version=16
|
node_version=16
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
function set_go_vars {
|
function set_go_vars {
|
||||||
ynh_use_go
|
|
||||||
|
|
||||||
export GOPATH="$install_dir/build/go"
|
export GOPATH="$install_dir/build/go"
|
||||||
export GOCACHE="$install_dir/build/.cache"
|
export GOCACHE="$install_dir/build/.cache"
|
||||||
|
|
||||||
go_shims_path=$goenv_install_dir/shims
|
go_shims_path=$goenv_install_dir/shims
|
||||||
go_path_full="$go_shims_path":"$(sudo -u $app bash -c 'echo $PATH')"
|
go_path_full="$go_shims_path":"$(ynh_exec_as_app bash -c 'echo $PATH')"
|
||||||
heif_lib_path="$install_dir/local/lib":"$(sudo -u $app bash -c 'echo $LIBRARY_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":"$(sudo -u $app bash -c 'echo $LD_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"
|
heif_cgo_cflags="-I$install_dir/local/include"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,13 +24,13 @@ function build_libheif {
|
||||||
export GOCACHE="$install_dir/build/.cache"
|
export GOCACHE="$install_dir/build/.cache"
|
||||||
|
|
||||||
pushd "$install_dir/libheif" || ynh_die
|
pushd "$install_dir/libheif" || ynh_die
|
||||||
ynh_exec_as "$app" mkdir build
|
ynh_exec_as_app mkdir build
|
||||||
pushd 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 ..
|
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
|
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
|
ninja install
|
||||||
popd
|
popd
|
||||||
popd || ynh_die
|
popd || ynh_die
|
||||||
|
@ -56,12 +51,12 @@ function build_api {
|
||||||
pushd "$install_dir/sources/api" || ynh_die
|
pushd "$install_dir/sources/api" || ynh_die
|
||||||
set +e
|
set +e
|
||||||
for i in {1..5}; do
|
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
|
sleep 5
|
||||||
done
|
done
|
||||||
set -e
|
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 "${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 build -o photoview . 2>&1
|
||||||
popd || ynh_die
|
popd || ynh_die
|
||||||
|
|
||||||
cp -T "$install_dir/sources/api/photoview" "$install_dir/output/photoview"
|
cp -T "$install_dir/sources/api/photoview" "$install_dir/output/photoview"
|
||||||
|
@ -69,35 +64,26 @@ function build_api {
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_ui {
|
function build_ui {
|
||||||
ynh_use_nodejs
|
|
||||||
|
|
||||||
pushd "$install_dir/sources/ui" || ynh_die
|
pushd "$install_dir/sources/ui" || ynh_die
|
||||||
ynh_replace_string -m "cd .. && " -r "" -f "package.json"
|
ynh_replace -m "cd .. && " -r "" -f "package.json"
|
||||||
# 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
|
||||||
ynh_exec_as "$app" touch ".yarnrc"
|
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 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 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 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 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 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 node_load_PATH" NODE_ENV=production npm install
|
||||||
# ynh_exec_as "$app" env "$ynh_node_load_PATH" NODE_ENV=production "$ynh_npm" run build
|
# ynh_exec_as_app node_load_PATH" NODE_ENV=production npm run build
|
||||||
popd || ynh_die
|
popd || ynh_die
|
||||||
|
|
||||||
cp -rT "$install_dir/sources/ui/dist" "$install_dir/output/ui"
|
cp -rT "$install_dir/sources/ui/dist" "$install_dir/output/ui"
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_sources {
|
function cleanup_sources {
|
||||||
ynh_secure_remove --file="$install_dir/libheif"
|
ynh_safe_rm "$install_dir/libheif"
|
||||||
ynh_secure_remove --file="$install_dir/sources"
|
ynh_safe_rm "$install_dir/sources"
|
||||||
ynh_secure_remove --file="$install_dir/go"
|
ynh_safe_rm "$install_dir/go"
|
||||||
ynh_secure_remove --file="$install_dir/.cache/go-build"
|
ynh_safe_rm "$install_dir/.cache/go-build"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
|
@ -8,48 +8,45 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$install_dir"
|
ynh_backup "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP DATA DIR
|
# BACKUP THE APP DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$data_dir" --is_big
|
ynh_backup "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE SYSTEM CONFIGURATION
|
# 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
|
# BACKUP VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/var/log/$app/"
|
ynh_backup "/var/log/$app/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# 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
|
# 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)."
|
||||||
|
|
|
@ -10,34 +10,34 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# 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
|
# 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
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_config --template=".env" --destination="$install_dir/output/.env"
|
ynh_config_add --template=".env" --destination="$install_dir/output/.env"
|
||||||
chown "$app:$app" "$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
|
# 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
|
# 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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -10,40 +10,40 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL GO
|
# 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
|
# 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
|
# 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 --dest_dir="$install_dir/sources"
|
||||||
ynh_setup_source --source_id=libheif --dest_dir="$install_dir/libheif"
|
ynh_setup_source --source_id=libheif --dest_dir="$install_dir/libheif"
|
||||||
|
|
||||||
mkdir -p "$install_dir/output/"{data,ui}
|
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"
|
chown -R "$app:$app" "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Compiling libheif..." --weight=10
|
ynh_script_progression "Compiling libheif..."
|
||||||
build_libheif
|
build_libheif
|
||||||
|
|
||||||
ynh_script_progression --message="Compiling Go API..." --weight=10
|
ynh_script_progression "Compiling Go API..."
|
||||||
build_api
|
build_api
|
||||||
|
|
||||||
ynh_script_progression --message="Building static UI files..." --weight=10
|
ynh_script_progression "Building static UI files..."
|
||||||
build_ui
|
build_ui
|
||||||
|
|
||||||
cleanup_sources
|
cleanup_sources
|
||||||
|
@ -51,36 +51,36 @@ cleanup_sources
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# 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"
|
ynh_config_add --template=".env" --destination="$install_dir/output/.env"
|
||||||
chown "$app:$app" "$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
|
# 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
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# 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"
|
yunohost service add "$app" --description="Photoview photo manager API" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_config_add_logrotate
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# 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
|
# 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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -10,35 +10,35 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# 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`)
|
# 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"
|
yunohost service remove "$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_config_remove_systemd
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_config_remove_logrotate
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
# Remove other various files specific to the app... such as :
|
# Remove other various files specific to the app... such as :
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing Go..." --weight=5
|
ynh_script_progression "Removing Go..."
|
||||||
ynh_remove_go
|
ynh_go_remove
|
||||||
|
|
||||||
ynh_script_progression --message="Removing NodeJS..." --weight=5
|
ynh_script_progression "Removing NodeJS..."
|
||||||
ynh_remove_nodejs
|
ynh_nodejs_remove
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -11,37 +11,37 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL GO
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# SPECIFIC RESTORATION
|
||||||
|
@ -52,32 +52,32 @@ set_go_vars
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/var/log/$app/"
|
ynh_restore "/var/log/$app/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEM CONFIGURATIONS
|
# 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
|
systemctl enable "$app.service" --quiet
|
||||||
yunohost service add "$app" --description="Photoview photo manager API" --log="/var/log/$app/$app.log"
|
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
|
# 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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -10,58 +10,58 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# 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
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression "Ensuring downward compatibility..."
|
||||||
|
|
||||||
if [ ! -d "$install_dir/sources" ]; then
|
if [ ! -d "$install_dir/sources" ]; then
|
||||||
# Final cleanup...
|
# Final cleanup...
|
||||||
ynh_secure_remove --file="$install_dir"
|
ynh_safe_rm "$install_dir"
|
||||||
mkdir -p "$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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL GO
|
# 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
|
# 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
|
# 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 --dest_dir="$install_dir/sources" --full_replace
|
||||||
ynh_setup_source --source_id=libheif --dest_dir="$install_dir/libheif" --full_replace=1
|
ynh_setup_source --source_id=libheif --dest_dir="$install_dir/libheif" --full_replace
|
||||||
mkdir -p "$install_dir/output/"{data,ui}
|
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"
|
chown -R "$app:$app" "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Compiling libheif..." --weight=70
|
ynh_script_progression "Compiling libheif..."
|
||||||
build_libheif
|
build_libheif
|
||||||
|
|
||||||
ynh_script_progression --message="Compiling Go API..." --weight=165
|
ynh_script_progression "Compiling Go API..."
|
||||||
build_api
|
build_api
|
||||||
|
|
||||||
ynh_script_progression --message="Building static UI files..." --weight=45
|
ynh_script_progression "Building static UI files..."
|
||||||
build_ui
|
build_ui
|
||||||
|
|
||||||
cleanup_sources
|
cleanup_sources
|
||||||
|
@ -69,35 +69,35 @@ cleanup_sources
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# 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"
|
ynh_config_add --template=".env" --destination="$install_dir/output/.env"
|
||||||
chown "$app:$app" "$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
|
# 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
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# 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"
|
yunohost service add "$app" --description="Photoview photo manager API" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --non-append
|
ynh_config_add_logrotate
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# 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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
Loading…
Add table
Reference in a new issue