1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/streams_ynh.git synced 2024-09-03 20:26:20 +02:00

Final refinements

This commit is contained in:
dragondaddy 2024-03-14 16:22:08 +01:00
parent 79bf776c8e
commit c706603409
2 changed files with 33 additions and 11 deletions

View file

@ -19,6 +19,7 @@ random_string="$(ynh_string_random --length=48)"
fpm_footprint="medium"
fpm_free_footprint=0
fpm_usage="medium"
git_branch_mode="0"
#=================================================
# STORE SETTINGS FROM MANIFEST
@ -31,6 +32,7 @@ ynh_app_setting_set --app=$app --key=random_string --value=$random_string
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
ynh_app_setting_set --app=$app --key=git_branch_mode --value="$git_branch_mode"
#=================================================
# CREATE A DATABASE
@ -51,7 +53,7 @@ chown -R $app:www-data "$install_dir"
git config --system --add safe.directory $install_dir
# Download, check integrity, uncompress and patch the source from GitHub
git clone https://codeberg.org/streams/streams.git "$install_dir" --quiet
ynh_exec_as $app git clone https://codeberg.org/streams/streams.git "$install_dir" --quiet
touch "$install_dir/php.log"
mkdir -p "$install_dir/store"

View file

@ -47,13 +47,28 @@ if [ -z "$fpm_usage" ]; then
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# Make sure that git_branch_mode exists with relevant value
git_branch_mode_status="$(cd "$install_dir" && sudo -u $app git branch --show-current)" 2> /dev/null
if echo $git_branch_mode_status | grep -q "release"
then
git_branch_mode="0"
ynh_app_setting_set --app=$app --key=git_branch_mode --value="$git_branch_mode"
elif echo $git_branch_mode_status | grep -q "dev"
then
git_branch_mode="1"
ynh_app_setting_set --app=$app --key=git_branch_mode --value="$git_branch_mode"
else
ynh_print_err --message="You need to use \"release\" or \"dev\" branch, please handle this in command line"
exit 0
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_script_progression --message="Upgrading source files..." --weight=1
# First we save what we need to keep
mv $install_dir/store $data_dir/
@ -69,7 +84,14 @@ then
git config --system --add safe.directory $install_dir
git clone https://codeberg.org/streams/streams.git "$install_dir" --quiet
ynh_exec_as $app git clone https://codeberg.org/streams/streams.git "$install_dir" --quiet
ynh_app_setting_get --app=$app --key=git_branch_mode
if [[ -n $git_branch_mode ]] && [ "$git_branch_mode" -eq "1" ]
then
ynh_print_info "Switching to \"dev\" branch"
(cd "$install_dir" && ynh_exec_as $app git checkout dev)
fi
# We restore what we previously saved
mv $data_dir/store $install_dir/
@ -134,16 +156,14 @@ ynh_script_progression --message="Setuping cron job..." --weight=1
# We're ready for the moment when 'Code' is renamed 'src'
# Check for renaming of 'Code' folder to 'src'
if [ -d /var/www/$app/src ]
if [ -d $install_dir/src ]
then
sed -i 's/Code/src/' ../conf/cronjobs
fi
if [ -d /var/www/$app/Code ]
then
sed -i "/finished/ i\# Check if 'Code' folder was renamed 'src' and adapt cronjob accordingly" conf/daily-update.sh
sed -i "/finished/ i\if [ -d \/var\/www\/$app\/src ] ; then"
sed -i "/finished/ i\ sed -i \'s\/Code\/src\/\' \/etc\/cron.d\/$app"
sed -i "/finished/ i\fi"
else
sed -i "/finished/ i\# Check if 'Code' folder was renamed 'src' and adapt cronjob accordingly" ../conf/daily-update.sh
sed -i "/finished/ i\if [ -d \/var\/www\/$app\/src ] ; then" ../conf/daily-update.sh
sed -i "/finished/ i\ sed -i \'s\/Code\/src\/\' \/etc\/cron.d\/$app" ../conf/daily-update.sh
sed -i "/finished/ i\fi" ../conf/daily-update.sh
fi
# Set up cron job