mirror of
https://github.com/YunoHost-Apps/movim_ynh.git
synced 2024-09-03 19:46:19 +02:00
s/DESTDIR/final_path/
This commit is contained in:
parent
0b331472ca
commit
5182be4389
4 changed files with 39 additions and 28 deletions
|
@ -9,9 +9,6 @@ GIT_REPO="https://github.com/movim/movim"
|
|||
# Commit to checkout
|
||||
HEAD_COMMIT="ee249f1e37b548c71b9a339dd358fbd2136e3291"
|
||||
|
||||
# Source code destination directory
|
||||
DESTDIR="/var/www/movim"
|
||||
|
||||
# App package root directory should be the parent folder
|
||||
PKGDIR=$(cd ../; pwd)
|
||||
|
||||
|
@ -22,7 +19,7 @@ PKGDIR=$(cd ../; pwd)
|
|||
# Execute a command as movim user in the destination directory
|
||||
# usage: exec_cmd COMMAND [ARG ...]
|
||||
exec_cmd() {
|
||||
(cd "$DESTDIR" \
|
||||
(cd "$final_path" \
|
||||
&& sudo sudo -u movim "$@")
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
|
||||
# TODO: final_path=/var/www/$app
|
||||
test ! -e "$DESTDIR" || ynh_die "This path already contains a folder"
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
@ -101,6 +101,8 @@ ynh_install_app_dependencies php5-gd php5-curl php5-imagick php5-cli php5-zmq
|
|||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
|
||||
# Download Movim source code
|
||||
tmp_path=/tmp/movim-git
|
||||
sudo rm -rf "$tmp_path"
|
||||
|
@ -124,7 +126,7 @@ sed -i "s@'/ws/'@'${path_url%/}/ws/'@g" \
|
|||
"${tmp_path}/app/assets/js/movim_websocket.js"
|
||||
|
||||
# Move Movim source code
|
||||
sudo mv "$tmp_path" "$DESTDIR"
|
||||
sudo mv "$tmp_path" "$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -137,14 +139,14 @@ sudo useradd -d /var/www/movim -s /bin/sh movim
|
|||
# SET PERMISSIONS
|
||||
#=================================================
|
||||
|
||||
sudo chown -R movim:www-data "$DESTDIR"
|
||||
sudo find "${DESTDIR}/" -type f -print0 | sudo xargs -0 chmod 0644
|
||||
sudo find "${DESTDIR}/" -type d -print0 | sudo xargs -0 chmod 0755
|
||||
sudo chmod 400 "${DESTDIR}/config/db.inc.php"
|
||||
sudo chown -R movim:www-data "$final_path"
|
||||
sudo find "${final_path}/" -type f -print0 | sudo xargs -0 chmod 0644
|
||||
sudo find "${final_path}/" -type d -print0 | sudo xargs -0 chmod 0755
|
||||
sudo chmod 400 "${final_path}/config/db.inc.php"
|
||||
|
||||
# Install PHP dependencies using composer
|
||||
(curl -sS https://getcomposer.org/installer \
|
||||
| exec_cmd php -- --install-dir="$DESTDIR" \
|
||||
| exec_cmd php -- --install-dir="$final_path" \
|
||||
&& exec_cmd php composer.phar config --global discard-changes true \
|
||||
&& exec_cmd php composer.phar install --no-interaction) \
|
||||
|| ynh_die "Unable to install Movim dependencies."
|
||||
|
@ -166,7 +168,7 @@ exec_cmd php mud.php config --loglevel=1 \
|
|||
|
||||
# Copy init script or systemd service
|
||||
sudo sed -i "s@YHURL@${domain}${path_url}@g" ../conf/movim.{service,init}
|
||||
sudo sed -i "s@YHDIR@${DESTDIR}@g" ../conf/movim.{service,init}
|
||||
sudo sed -i "s@YHDIR@${final_path}@g" ../conf/movim.{service,init}
|
||||
sudo sed -i "s@YHPORT@${port}@g" ../conf/movim.{service,init}
|
||||
if [ -d /run/systemd/system ]; then
|
||||
sudo cp ../conf/movim.service /etc/systemd/system/
|
||||
|
@ -194,7 +196,7 @@ sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/movim.conf
|
|||
|
||||
# Nginx configuration
|
||||
sed -i "s@PATHTOCHANGE@$path_url@g" ../conf/nginx.conf
|
||||
sed -i "s@ALIASTOCHANGE@$DESTDIR/@g" ../conf/nginx.conf
|
||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
||||
sed -i "s@YHPORT@$port@g" ../conf/nginx.conf
|
||||
sed -i "s@//ws/@/ws/@g" ../conf/nginx.conf # Avoid duplicate /
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf
|
||||
|
|
|
@ -17,6 +17,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
@ -70,7 +71,7 @@ ynh_mysql_drop_user "$db_user" || true
|
|||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
sudo rm -rf /var/www/movim
|
||||
sudo rm -rf "$final_path"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -22,6 +22,17 @@ port=$(ynh_app_setting_get "$app" port)
|
|||
ssoenabled=$(ynh_app_setting_get "$app" ssoenabled)
|
||||
public_site=$(ynh_app_setting_get "$app" public_site)
|
||||
timezone=$(cat /etc/timezone)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path="/var/www/$app"
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# ACTIVE TRAP
|
||||
|
@ -61,7 +72,7 @@ ynh_install_app_dependencies php5-zmq
|
|||
#=================================================
|
||||
|
||||
# Init git repository as needed
|
||||
if [ ! -d "${DESTDIR}/.git" ]; then
|
||||
if [ ! -d "${final_path}/.git" ]; then
|
||||
tmp_path=/tmp/movim-git
|
||||
sudo rm -rf "$tmp_path"
|
||||
|
||||
|
@ -69,16 +80,16 @@ if [ ! -d "${DESTDIR}/.git" ]; then
|
|||
(git clone "$GIT_REPO" "$tmp_path" \
|
||||
&& cd "$tmp_path" && git checkout "$HEAD_COMMIT") \
|
||||
|| ynh_die "Unable to download Movim source code."
|
||||
sudo cp "${DESTDIR}/config/db.inc.php" "${tmp_path}/config/db.inc.php"
|
||||
sudo cp "${final_path}/config/db.inc.php" "${tmp_path}/config/db.inc.php"
|
||||
|
||||
# Replace current source code
|
||||
sudo rm -rf "$DESTDIR"
|
||||
sudo mv "$tmp_path" "$DESTDIR"
|
||||
sudo chown -R movim:www-data "$DESTDIR"
|
||||
sudo rm -rf "$final_path"
|
||||
sudo mv "$tmp_path" "$final_path"
|
||||
sudo chown -R movim:www-data "$final_path"
|
||||
|
||||
# Install composer for PHP dependencies
|
||||
curl -sS https://getcomposer.org/installer \
|
||||
| exec_cmd php -- --install-dir="$DESTDIR"
|
||||
| exec_cmd php -- --install-dir="$final_path"
|
||||
fi
|
||||
|
||||
# Update Movim source code
|
||||
|
@ -87,7 +98,7 @@ fi
|
|||
|| ynh_die "Unable to download Movim source code."
|
||||
## TODO: consider installation in a subpath
|
||||
exec_cmd sed -i "s@'/ws/'@'${path_url%/}/ws/'@g" \
|
||||
"${DESTDIR}/app/assets/js/movim_websocket.js"
|
||||
"${final_path}/app/assets/js/movim_websocket.js"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -101,10 +112,10 @@ ynh_system_user_exists movim \
|
|||
# SET PERMISSIONS
|
||||
#=================================================
|
||||
|
||||
sudo chown -R movim:www-data "$DESTDIR"
|
||||
sudo find "${DESTDIR}/" -type f -print0 | sudo xargs -0 chmod 0644
|
||||
sudo find "${DESTDIR}/" -type d -print0 | sudo xargs -0 chmod 0755
|
||||
sudo chmod 400 "${DESTDIR}/config/db.inc.php"
|
||||
sudo chown -R movim:www-data "$final_path"
|
||||
sudo find "${final_path}/" -type f -print0 | sudo xargs -0 chmod 0644
|
||||
sudo find "${final_path}/" -type d -print0 | sudo xargs -0 chmod 0755
|
||||
sudo chmod 400 "${final_path}/config/db.inc.php"
|
||||
|
||||
#=================================================
|
||||
# install PHP dependencies
|
||||
|
@ -161,7 +172,7 @@ fi
|
|||
|
||||
# Update init scripts
|
||||
sudo sed -i "s@YHURL@${domain}${path_url}@g" ../conf/movim.{service,init}
|
||||
sudo sed -i "s@YHDIR@${DESTDIR}@g" ../conf/movim.{service,init}
|
||||
sudo sed -i "s@YHDIR@${final_path}@g" ../conf/movim.{service,init}
|
||||
sudo sed -i "s@YHPORT@${port}@g" ../conf/movim.{service,init}
|
||||
if [ -d /run/systemd/system ]; then
|
||||
sudo rm -f /lib/systemd/system/movim.service
|
||||
|
@ -189,7 +200,7 @@ sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/movim.conf
|
|||
|
||||
# Nginx configuration
|
||||
sed -i "s@PATHTOCHANGE@$path_url@g" ../conf/nginx.conf
|
||||
sed -i "s@ALIASTOCHANGE@$DESTDIR/@g" ../conf/nginx.conf
|
||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
||||
sed -i "s@YHPORT@$port@g" ../conf/nginx.conf
|
||||
sed -i "s@//ws/@/ws/@g" ../conf/nginx.conf # Avoid duplicate /
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf
|
||||
|
|
Loading…
Reference in a new issue