upgrade 2.64 KB
Newer Older
Spctrl's avatar
Spctrl committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# LOAD SETTINGS
#=================================================

app=$YNH_APP_INSTANCE_NAME

domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
22
port=$(ynh_app_setting_get $app port)
23
db_name=$(ynh_app_setting_get $app db_name)
Spctrl's avatar
Spctrl committed
24

root's avatar
root committed
25 26 27 28 29 30 31 32
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================

ynh_print_info "Creating backup"

ynh_backup_before_upgrade
ynh_clean_setup () {
root's avatar
root committed
33
	# restore it if the upgrade fails
root's avatar
root committed
34 35 36 37 38 39
	ynh_restore_upgradebackup
}

# Exit if an error occurs during the execution of the script
ynh_abort_if_errors

Spctrl's avatar
Spctrl committed
40 41 42 43
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================

44
ynh_print_info "Ensuring backwards compatibility"
root's avatar
root committed
45

46 47
# TODO: The following lines seems to break the whole thing. First make it work on install, then check this out.
## Pleroma sets the headers so we don't need to do it
Spctrl's avatar
Spctrl committed
48 49
#if (cat "/etc/nginx/conf.d/$domain.d/$app.conf" | grep 'add_header')
#then
50 51 52 53 54
# cp -rf "../conf/nginx.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
# ynh_replace_string "{APP}" "$app" "/etc/nginx/conf.d/$domain.d/$app.conf"
# ynh_replace_string "{PORT}" "$port" "/etc/nginx/conf.d/$domain.d/$app.conf"
# ynh_replace_string "add_header" "# add_header" "/etc/nginx/conf.d/$domain.conf"
# systemctl reload nginx
Spctrl's avatar
Spctrl committed
55
#fi
Spctrl's avatar
Spctrl committed
56 57 58 59

#=================================================
# STANDARD UPGRADE STEPS
#=================================================
Spctrl's avatar
Spctrl committed
60
# PULL CHANGES AND SPECIFIC SETUP
Spctrl's avatar
Spctrl committed
61
#=================================================
root's avatar
root committed
62 63 64

ynh_print_info "Doing actual upgrade"

65
new_branch="0.9.9-beta-2"
66

67
systemctl stop $app
68 69
# First we revert to the last commit, untracked files are save from this. Then we pull, I added --no-edit just to be sure.
# Then we checkout the new version and do some Pleroma magic.
70
# TODO: Keep track of reverted files
71
su - $app -c "cd $final_path/pleroma;git reset --hard;git pull --no-edit;git checkout $new_branch;MIX_ENV=prod mix deps.get;MIX_ENV=prod mix ecto.migrate;"
Spctrl's avatar
Spctrl committed
72 73

#=================================================
74
# RESTART PLEROMA
Spctrl's avatar
Spctrl committed
75 76
#=================================================

root's avatar
root committed
77 78
ynh_print_info "Restarting your new and improved version of Pleroma"

79
systemctl restart $app
Spctrl's avatar
Spctrl committed
80