2016-08-15 15:38:50 +02:00
|
|
|
#
|
|
|
|
# Common variables
|
|
|
|
#
|
2018-02-07 00:31:25 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
final_path="/opt/$app"
|
|
|
|
dbname=$app
|
|
|
|
dbuser=$app
|
2018-02-07 23:49:32 +01:00
|
|
|
DATADIR="/home/$app"
|
|
|
|
REPO_PATH="$DATADIR/repositories"
|
|
|
|
DATA_PATH="$DATADIR/data"
|
2016-08-15 15:38:50 +02:00
|
|
|
|
|
|
|
# Detect the system architecture to download the right tarball
|
2016-10-18 00:09:26 +02:00
|
|
|
# NOTE: `uname -m` is more accurate and universal than `arch`
|
|
|
|
# See https://en.wikipedia.org/wiki/Uname
|
|
|
|
if [ -n "$(uname -m | grep 64)" ]; then
|
2018-02-07 00:31:25 +01:00
|
|
|
architecture="x86-64"
|
2016-10-18 00:09:26 +02:00
|
|
|
elif [ -n "$(uname -m | grep 86)" ]; then
|
2018-02-07 00:31:25 +01:00
|
|
|
architecture="i386"
|
2016-10-18 00:09:26 +02:00
|
|
|
elif [ -n "$(uname -m | grep arm)" ]; then
|
2018-02-07 00:31:25 +01:00
|
|
|
architecture="arm"
|
2016-10-18 00:09:26 +02:00
|
|
|
else
|
2017-04-05 21:06:22 +02:00
|
|
|
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
|
|
|
your hardware and the result of the command \"uname -m\"." 1
|
2016-10-18 00:09:26 +02:00
|
|
|
fi
|
2016-08-15 15:38:50 +02:00
|
|
|
|
2018-02-07 00:31:25 +01:00
|
|
|
create_dir() {
|
|
|
|
mkdir -p "$final_path/custom/conf"
|
|
|
|
mkdir -p "$REPO_PATH"
|
|
|
|
mkdir -p "$DATA_PATH/avatars"
|
|
|
|
mkdir -p "$DATA_PATH/attachments"
|
|
|
|
mkdir -p "/var/log/$app"
|
|
|
|
}
|
|
|
|
|
|
|
|
config_nginx() {
|
|
|
|
if [ "$path_url" != "/" ]
|
|
|
|
then
|
|
|
|
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
|
|
|
fi
|
|
|
|
ynh_add_nginx_config
|
|
|
|
}
|
|
|
|
|
|
|
|
config_gogs() {
|
2018-02-08 00:09:28 +01:00
|
|
|
ynh_backup_if_checksum_is_different "$final_path/custom/conf/app.ini"
|
|
|
|
|
2018-02-07 00:31:25 +01:00
|
|
|
cp ../conf/app.ini "$final_path"/custom/conf
|
2018-02-08 00:09:28 +01:00
|
|
|
|
2018-02-07 00:31:25 +01:00
|
|
|
if [ "$path_url" = "/" ]
|
|
|
|
then
|
2018-02-08 00:09:28 +01:00
|
|
|
ynh_replace_string "__URL__" "$domain" "$final_path/custom/conf/app.ini"
|
2018-02-07 00:31:25 +01:00
|
|
|
else
|
2018-02-08 00:09:28 +01:00
|
|
|
ynh_replace_string "__URL__" "$domain${path_url%/}" "$final_path/custom/conf/app.ini"
|
2018-02-07 00:31:25 +01:00
|
|
|
fi
|
2018-02-08 00:09:28 +01:00
|
|
|
|
|
|
|
ynh_replace_string "__REPOS_PATH__" "$REPO_PATH" "$final_path/custom/conf/app.ini"
|
|
|
|
ynh_replace_string "__DB_PASSWORD__" "$dbpass" "$final_path/custom/conf/app.ini"
|
|
|
|
ynh_replace_string "__DB_USER__" "$dbuser" "$final_path/custom/conf/app.ini"
|
|
|
|
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/custom/conf/app.ini"
|
|
|
|
ynh_replace_string "__KEY__" "$key" "$final_path/custom/conf/app.ini"
|
|
|
|
ynh_replace_string "__DATA_PATH__" "$DATA_PATH" "$final_path/custom/conf/app.ini"
|
|
|
|
ynh_replace_string "__PORT__" $port "$final_path/custom/conf/app.ini"
|
|
|
|
|
|
|
|
ynh_store_file_checksum "$final_path/custom/conf/app.ini"
|
2018-02-07 00:31:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
set_permission() {
|
|
|
|
chown -R $app:$app "$final_path"
|
|
|
|
chown -R $app:$app "/home/$app"
|
|
|
|
chown -R $app:$app "/var/log/$app"
|
|
|
|
chmod u=rwX,g=rX,o= "$final_path"
|
|
|
|
chmod u=rwX,g=rX,o= "/home/$app"
|
|
|
|
chmod u=rwX,g=rX,o= "/var/log/$app"
|
|
|
|
}
|