mirror of
https://github.com/YunoHost-Apps/etherpad_ynh.git
synced 2024-09-03 18:36:10 +02:00
65 lines
2 KiB
Bash
65 lines
2 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$1
|
|
path=$2
|
|
is_public=$3
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a etherpadlite
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# Generate random password
|
|
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
|
|
|
|
# Generate random key
|
|
key=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{40\}\).*/\1/p')
|
|
|
|
# Use 'etherpadlite' as database name and user
|
|
db_user=etherpadlite
|
|
|
|
# Initialize database and store mysql password for upgrade
|
|
sudo yunohost app initdb $db_user -p $db_pwd
|
|
sudo yunohost app setting etherpadlite mysqlpwd -v $db_pwd
|
|
|
|
# Install dependances
|
|
sudo apt-get install nodejs-legacy npm -y
|
|
|
|
# Copy files to the right place
|
|
final_path=/var/www/etherpadlite
|
|
sudo mkdir -p $final_path
|
|
sudo cp -a ../sources/* $final_path
|
|
sudo cp ../conf/settings.json $final_path
|
|
sudo cp ../conf/etherpad-lite /etc/init.d/
|
|
sudo chmod +x /etc/init.d/etherpad-lite
|
|
sudo update-rc.d etherpad-lite defaults
|
|
sudo mkdir /var/log/etherpad-lite/
|
|
su - www -c "touch /var/log/etherpad-lite/etherpad-lite.log"
|
|
|
|
|
|
sudo $final_path/bin/installDeps.sh > /dev/null 2>&1
|
|
sudo npm install forever -g > /dev/null 2>&1
|
|
|
|
# Change variables in Wordpress configuration
|
|
sudo sed -i "s/yunouser/$db_user/g" $final_path/settings.json
|
|
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/settings.json
|
|
sudo sed -i "s/yunobase/$db_user/g" $final_path/settings.json
|
|
sudo sed -i "s/KEY/$db_user/g" $final_path/settings.json
|
|
|
|
# Set permissions to roundcube directory
|
|
sudo chown -R www-data: $final_path
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/etherpadlite.conf
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
sudo service nginx reload
|
|
if [ $is_public = "Yes" ];
|
|
then
|
|
sudo yunohost app setting etherpadlite skipped_uris -v "/"
|
|
fi
|
|
sudo yunohost app ssowatconf
|