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
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
NODEJS_VERSION="8.2.1"
|
||||
|
||||
#=================================================
|
||||
#=================================================
|
||||
# TESTING
|
||||
|
@ -156,35 +161,66 @@ ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
|
|||
# BACKUP
|
||||
#=================================================
|
||||
|
||||
BACKUP_FAIL_UPGRADE () {
|
||||
WARNING echo "Upgrade failed."
|
||||
# Restore a previous backup if the upgrade process 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 '-'
|
||||
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
|
||||
sudo yunohost app remove $app # Supprime l'application avant de la restaurer.
|
||||
sudo yunohost backup restore --ignore-hooks $app_bck-pre-upgrade$backup_number --apps $app --force # Restore the backup if upgrade failed
|
||||
# Check if a existing backup can be found before remove and restore the application.
|
||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$backup_number
|
||||
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."
|
||||
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
|
||||
old_backup_number=2
|
||||
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.
|
||||
backup_number=2 # Et passe le numéro de l'archive à 2
|
||||
# Check if a backup already exist with the prefix 1.
|
||||
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
|
||||
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.
|
||||
if [ "$?" -eq 0 ]; then # Si le backup est un succès, supprime l'archive précédente.
|
||||
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.
|
||||
QUIET sudo yunohost backup delete $app_bck-pre-upgrade$old_backup_number
|
||||
# Create another backup
|
||||
sudo yunohost backup create --ignore-hooks --apps $app --name $app_bck-pre-upgrade$backup_number
|
||||
if [ "$?" -eq 0 ]
|
||||
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
|
||||
else # Si le backup a échoué
|
||||
else
|
||||
ynh_die "Backup failed, the upgrade process was aborted."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
|
||||
human=$(numfmt --to=iec --from-unit=1K $1)
|
||||
echo $human
|
||||
|
@ -248,7 +284,7 @@ ynh_use_nodejs () {
|
|||
|
||||
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
|
||||
eval $load_n_path; $nodejs_use_version
|
||||
|
@ -884,13 +920,6 @@ ynh_find_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() {
|
||||
# Add user if not exist
|
||||
id -g "$app" &>/dev/null || sudo addgroup "$app" --system --quiet
|
||||
|
|
|
@ -102,7 +102,8 @@ ynh_use_logrotate
|
|||
#=================================================
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue