2020-01-05 19:49:24 +01:00
|
|
|
#!/bin/bash
|
2017-07-03 21:07:56 +02:00
|
|
|
|
2020-01-05 19:49:24 +01:00
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
2017-07-03 21:07:56 +02:00
|
|
|
|
2023-07-09 21:05:05 +02:00
|
|
|
YNH_PHP_VERSION="7.4"
|
|
|
|
|
|
|
|
php_dependencies="php$YNH_PHP_VERSION-zip php$YNH_PHP_VERSION-curl php$YNH_PHP_VERSION-gd"
|
2022-09-18 03:17:45 +02:00
|
|
|
|
|
|
|
# dependencies used by the app (must be on a single line)
|
|
|
|
pkg_dependencies="$php_dependencies"
|
2020-01-05 19:49:24 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PERSONAL HELPERS
|
|
|
|
#=================================================
|
2022-07-28 03:39:57 +02:00
|
|
|
|
2017-07-03 21:07:56 +02:00
|
|
|
# Check if directory/file already exists (path in argument)
|
|
|
|
myynh_check_path () {
|
2020-01-05 19:49:24 +01:00
|
|
|
[ -z "$1" ] && ynh_die --message="No argument supplied"
|
|
|
|
[ ! -e "$1" ] || ynh_die --message="$1 already exists"
|
2017-07-03 21:07:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create directory only if not already exists (path in argument)
|
|
|
|
myynh_create_dir () {
|
2020-01-05 19:49:24 +01:00
|
|
|
[ -z "$1" ] && ynh_die --message="No argument supplied"
|
2017-10-11 21:21:48 +02:00
|
|
|
[ -d "$1" ] || mkdir -p "$1"
|
2017-07-03 21:07:56 +02:00
|
|
|
}
|
|
|
|
|
2017-09-22 19:33:28 +02:00
|
|
|
# Clean & copy files needed to final folder
|
|
|
|
myynh_clean_source () {
|
2020-01-05 19:49:24 +01:00
|
|
|
find "$tmpdir" -type f -name ".htaccess" | xargs rm
|
2020-11-27 07:20:16 +01:00
|
|
|
[ -e "$tmpdir/.gitignore" ] && ynh_secure_remove "$tmpdir/.gitignore"
|
2017-09-22 19:33:28 +02:00
|
|
|
}
|
|
|
|
|
2017-07-07 17:03:57 +02:00
|
|
|
myynh_set_permissions () {
|
2017-10-11 21:21:48 +02:00
|
|
|
[ $(find "$final_path" -type f | wc -l) -gt 0 ] && find "$final_path" -type f | xargs chmod 0644
|
|
|
|
[ $(find "$final_path" -type d | wc -l) -gt 0 ] && find "$final_path" -type d | xargs chmod 0755
|
2022-07-28 03:39:57 +02:00
|
|
|
[ $(find "$datadir" -type f | wc -l) -gt 0 ] && find "$datadir" -type f | xargs chmod 0644
|
|
|
|
[ $(find "$datadir" -type d | wc -l) -gt 0 ] && find "$datadir" -type d | xargs chmod 0755
|
2022-07-28 15:28:59 +02:00
|
|
|
chmod -R o-rwx "$final_path"
|
2022-07-28 20:26:29 +02:00
|
|
|
chown -R $app:www-data "$final_path"
|
2022-07-28 15:28:59 +02:00
|
|
|
chmod -R o-rwx "$datadir"
|
2022-07-28 20:26:29 +02:00
|
|
|
chown -R $app:www-data "$datadir"
|
2017-10-11 21:21:48 +02:00
|
|
|
}
|
2019-11-18 10:23:03 +01:00
|
|
|
|
2019-11-18 16:26:21 +01:00
|
|
|
#Convert --data to --data-urlencode before ynh_local_curl
|
2020-01-05 19:49:24 +01:00
|
|
|
myynh_urlencode() {
|
2019-11-18 16:26:21 +01:00
|
|
|
local data
|
|
|
|
if [[ $# != 1 ]]; then
|
|
|
|
echo "Usage: $0 string-to-urlencode"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
data="$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "")"
|
|
|
|
if [[ $? != 3 ]]; then
|
|
|
|
echo "Unexpected error" 1>&2
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
echo "${data##/?}"
|
|
|
|
return 0
|
2019-11-18 10:23:03 +01:00
|
|
|
}
|
2020-01-05 19:49:24 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# EXPERIMENTAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
|
|
|
#=================================================
|