mirror of
https://github.com/YunoHost-Apps/photoprism_ynh.git
synced 2024-09-03 19:56:41 +02:00
commit
d3f665cd2e
12 changed files with 116 additions and 44 deletions
|
@ -19,7 +19,7 @@
|
|||
setup_public=1
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[Unit]
|
||||
Description=Small description of the service
|
||||
Description=AI-Powered Photos App for the Decentralized Web
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
* Known limitations:
|
||||
* Although reaching level 7, Photoprism hasn't yet been extensively tested in real conditions
|
||||
* Please use with **extreme care** if you install it on a test server !
|
||||
* Not tested yet with AMD architecture
|
||||
* Photoprism currently supports only one user. OIDC should be supported within a few months
|
||||
* Photoprism requires an important amount of RAM and disk to install or to work properly
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "AI-Powered Photos App for the Decentralized Web",
|
||||
"fr": "Gestion de photos en ligne"
|
||||
},
|
||||
"version": "2022.28.05~ynh1",
|
||||
"version": "2022.05.28~ynh2",
|
||||
"url": "photoprism.app",
|
||||
"upstream": {
|
||||
"license": "AGPL-3.0-only",
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# Tag name of the installed version
|
||||
PHOTOPRISM_VERSION="220528-efb5d710"
|
||||
|
||||
MEMORY_NEEDED="3000"
|
||||
NODEJS_VERSION=14
|
||||
GO_VERSION="1.18"
|
||||
|
||||
|
|
|
@ -28,10 +28,16 @@ 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)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
language_key=$(ynh_app_setting_get --app=$app --key=language)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -70,20 +76,18 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP LOGS
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
ynh_backup --src_path="/etc/$app/"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
|
|
@ -30,9 +30,13 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
|
|||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#db_user=$db_name
|
||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
language_key=$(ynh_app_setting_get --app=$app --key=language)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
source _common.sh
|
||||
source ynh_install_go
|
||||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -59,6 +60,7 @@ ynh_script_progression --message="Storing installation settings..." --time --wei
|
|||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language_key
|
||||
ynh_app_setting_set --app=$app --key=password --value=$password
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -84,6 +86,22 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1
|
|||
# Install go
|
||||
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
|
||||
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap is needed..."
|
||||
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||
# Need a minimum of 2.5Go of memory
|
||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -147,7 +165,7 @@ pushd "$final_path"
|
|||
# Setup tensorflow library
|
||||
./scripts/dist/install-tensorflow.sh
|
||||
# Setup node environment
|
||||
export NODE_OPTIONS=--max_old_space_size=512
|
||||
export NODE_OPTIONS=--max_old_space_size=1024
|
||||
# Build server from source
|
||||
ynh_use_nodejs
|
||||
env "$ynh_node_load_PATH" npm install -g npm
|
||||
|
@ -163,9 +181,8 @@ ynh_script_progression --message="Creating a data directory..." --time --weight=
|
|||
datadir=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
|
||||
mkdir -p $datadir
|
||||
mkdir "$datadir/assets/"
|
||||
mv "$final_path/build/assets/"* "$datadir/assets/"
|
||||
mkdir -p "$datadir/assets/"
|
||||
rsync -a "$final_path/build/assets/" "$datadir/assets/"
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -17,11 +18,15 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
|
|||
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)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
language_key=$(ynh_app_setting_get --app=$app --key=language)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -118,6 +123,9 @@ ynh_secure_remove --file="/etc/cron.d/$app"
|
|||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
# Remove swap
|
||||
ynh_del_swap
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source ../settings/scripts/ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -33,7 +34,11 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
language_key=$(ynh_app_setting_get --app=$app --key=language)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -84,14 +89,9 @@ ynh_script_progression --message="Restoring the data directory..." --time --weig
|
|||
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p $datadir
|
||||
mkdir -p "$datadir/assets/"
|
||||
rsync -a "$final_path/build/assets/" "$datadir/assets/"
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
||||
# such that the appropriate users (e.g. maybe www-data) can access
|
||||
# files in some cases.
|
||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
||||
# this will be treated as a security issue.
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
|
@ -106,6 +106,22 @@ ynh_script_progression --message="Reinstalling dependencies..." --time --weight=
|
|||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap is needed..."
|
||||
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||
# Need a minimum of 2.5Go of memory
|
||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
@ -115,15 +131,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
|||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..." --time --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/$app/"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
@ -139,6 +146,13 @@ ynh_script_progression --message="Restoring the logrotate configuration..." --ti
|
|||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logs..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
source _common.sh
|
||||
source ynh_install_go
|
||||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -19,9 +20,14 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
language_key=$(ynh_app_setting_get --app=$app --key=language)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -104,6 +110,22 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
|||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap is needed..."
|
||||
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||
# Need a minimum of 2.5Go of memory
|
||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
|
||||
#=================================================
|
||||
# BUILD PHOTOPRISM
|
||||
|
@ -118,11 +140,14 @@ pushd "$final_path"
|
|||
export GOBIN=$GOPATH/bin
|
||||
# Setup tensorflow library
|
||||
./scripts/dist/install-tensorflow.sh
|
||||
# Remove the former build file
|
||||
ynh_secure_remove --file="$final_path/build"
|
||||
# Setup node environment
|
||||
export NODE_OPTIONS=--max_old_space_size=1024
|
||||
# Build server from source
|
||||
ynh_secure_remove --file="$final_path/build"
|
||||
make all install DESTDIR=$final_path/build 2>&1
|
||||
ynh_use_nodejs
|
||||
env "$ynh_node_load_PATH" npm install -g npm
|
||||
env "$ynh_node_load_PATH" make dep-tensorflow dep-js dep-go build-js install DESTDIR=$final_path/build 2>&1
|
||||
ynh_secure_remove --file="$final_path/go"
|
||||
popd
|
||||
|
||||
|
@ -131,9 +156,7 @@ popd
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating data directory..." --time --weight=1
|
||||
|
||||
ynh_secure_remove --file="$datadir/assets"
|
||||
mkdir "$datadir/assets/"
|
||||
mv "$final_path/build/assets/"* "$datadir/assets/"
|
||||
rsync -a "$final_path/build/assets/" "$datadir/assets/"
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
|
|
|
@ -51,7 +51,6 @@ ynh_add_swap () {
|
|||
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
|
||||
if ! fallocate -l ${swap_size}K /swap_$app
|
||||
then
|
||||
echo "I'm also in !"
|
||||
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
|
||||
fi
|
||||
chmod 0600 /swap_$app
|
||||
|
|
Loading…
Add table
Reference in a new issue