mirror of
https://github.com/YunoHost-Apps/osjs_ynh.git
synced 2024-09-03 19:56:11 +02:00
Correction sources (#4)
* Create app.src * Update _common.sh * Update install
This commit is contained in:
parent
d68b2a4d9a
commit
f0feceb482
3 changed files with 55 additions and 22 deletions
3
conf/app.src
Normal file
3
conf/app.src
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
SOURCE_URL=https://github.com/os-js/OS.js/archive/v2.0.0-97.tar.gz
|
||||||
|
SOURCE_SUM=e48c016033554e17ac91a73cc62cc43e
|
||||||
|
SOURCE_SUM_PRG=md5sum
|
|
@ -1,5 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
NODEJS_VERSION="8.2.1"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
#=================================================
|
#=================================================
|
||||||
# TESTING
|
# TESTING
|
||||||
|
@ -156,35 +161,66 @@ ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
|
||||||
# BACKUP
|
# BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
BACKUP_FAIL_UPGRADE () {
|
# Restore a previous backup if the upgrade process failed
|
||||||
WARNING echo "Upgrade failed."
|
#
|
||||||
|
# usage:
|
||||||
|
# ynh_backup_before_upgrade
|
||||||
|
# ynh_clean_setup () {
|
||||||
|
# ynh_backup_after_failed_upgrade
|
||||||
|
# }
|
||||||
|
# ynh_abort_if_errors
|
||||||
|
#
|
||||||
|
ynh_backup_after_failed_upgrade () {
|
||||||
|
echo "Upgrade failed." >&2
|
||||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$backup_number; then # Vérifie l'existence de l'archive avant de supprimer l'application et de restaurer
|
# Check if a existing backup can be found before remove and restore the application.
|
||||||
sudo yunohost app remove $app # Supprime l'application avant de la restaurer.
|
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$backup_number
|
||||||
sudo yunohost backup restore --ignore-hooks $app_bck-pre-upgrade$backup_number --apps $app --force # Restore the backup if upgrade failed
|
then
|
||||||
|
# Remove the application then restore it
|
||||||
|
sudo yunohost app remove $app
|
||||||
|
# Restore the backup if the upgrade failed
|
||||||
|
sudo yunohost backup restore --ignore-hooks $app_bck-pre-upgrade$backup_number --apps $app --force
|
||||||
ynh_die "The app was restored to the way it was before the failed upgrade."
|
ynh_die "The app was restored to the way it was before the failed upgrade."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
BACKUP_BEFORE_UPGRADE () { # Backup the current version of the app, restore it if the upgrade fails
|
# Make a backup in case of failed upgrade
|
||||||
|
#
|
||||||
|
# usage:
|
||||||
|
# ynh_backup_before_upgrade
|
||||||
|
# ynh_clean_setup () {
|
||||||
|
# ynh_backup_after_failed_upgrade
|
||||||
|
# }
|
||||||
|
# ynh_abort_if_errors
|
||||||
|
#
|
||||||
|
ynh_backup_before_upgrade () {
|
||||||
backup_number=1
|
backup_number=1
|
||||||
old_backup_number=2
|
old_backup_number=2
|
||||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade1; then # Vérifie l'existence d'une archive déjà numéroté à 1.
|
# Check if a backup already exist with the prefix 1.
|
||||||
backup_number=2 # Et passe le numéro de l'archive à 2
|
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade1
|
||||||
|
then
|
||||||
|
# Prefix become 2 to preserve the previous backup
|
||||||
|
backup_number=2
|
||||||
old_backup_number=1
|
old_backup_number=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo yunohost backup create --ignore-hooks --apps $app --name $app_bck-pre-upgrade$backup_number # Créer un backup différent de celui existant.
|
# Create another backup
|
||||||
if [ "$?" -eq 0 ]; then # Si le backup est un succès, supprime l'archive précédente.
|
sudo yunohost backup create --ignore-hooks --apps $app --name $app_bck-pre-upgrade$backup_number
|
||||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$old_backup_number; then # Vérifie l'existence de l'ancienne archive avant de la supprimer, pour éviter une erreur.
|
if [ "$?" -eq 0 ]
|
||||||
QUIET sudo yunohost backup delete $app_bck-pre-upgrade$old_backup_number
|
then
|
||||||
|
# If the backup succedded, remove the previous backup
|
||||||
|
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$old_backup_number
|
||||||
|
then
|
||||||
|
# Remove the previous backup only if it exists
|
||||||
|
sudo yunohost backup delete $app_bck-pre-upgrade$old_backup_number > /dev/null
|
||||||
fi
|
fi
|
||||||
else # Si le backup a échoué
|
else
|
||||||
ynh_die "Backup failed, the upgrade process was aborted."
|
ynh_die "Backup failed, the upgrade process was aborted."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
|
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
|
||||||
human=$(numfmt --to=iec --from-unit=1K $1)
|
human=$(numfmt --to=iec --from-unit=1K $1)
|
||||||
echo $human
|
echo $human
|
||||||
|
@ -248,7 +284,7 @@ ynh_use_nodejs () {
|
||||||
|
|
||||||
load_n_path="[[ :$PATH: == *\":$n_install_dir/bin:\"* ]] || PATH=\"$n_install_dir/bin:$PATH\""
|
load_n_path="[[ :$PATH: == *\":$n_install_dir/bin:\"* ]] || PATH=\"$n_install_dir/bin:$PATH\""
|
||||||
|
|
||||||
nodejs_use_version="n $nodejs_version"
|
nodejs_use_version="n -q $nodejs_version"
|
||||||
|
|
||||||
# "Load" a version of node
|
# "Load" a version of node
|
||||||
eval $load_n_path; $nodejs_use_version
|
eval $load_n_path; $nodejs_use_version
|
||||||
|
@ -884,13 +920,6 @@ ynh_find_port () {
|
||||||
echo $port
|
echo $port
|
||||||
}
|
}
|
||||||
|
|
||||||
extract_source() {
|
|
||||||
final_path=/var/www/$app
|
|
||||||
sudo rm -rf $final_path
|
|
||||||
sudo git clone https://github.com/os-js/OS.js.git $final_path \
|
|
||||||
|| ynh_die "Unable to download source"
|
|
||||||
}
|
|
||||||
|
|
||||||
pre_inst_os.js() {
|
pre_inst_os.js() {
|
||||||
# Add user if not exist
|
# Add user if not exist
|
||||||
id -g "$app" &>/dev/null || sudo addgroup "$app" --system --quiet
|
id -g "$app" &>/dev/null || sudo addgroup "$app" --system --quiet
|
||||||
|
|
|
@ -102,7 +102,8 @@ ynh_use_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
extract_source
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
ynh_setup_source $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Files owned by root, www-data can just read
|
# Files owned by root, www-data can just read
|
||||||
|
|
Loading…
Add table
Reference in a new issue