1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/leed_ynh.git synced 2024-09-03 19:26:32 +02:00
leed_ynh/scripts/install
2014-06-17 17:42:54 -04:00

59 lines
1.8 KiB
Bash

#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
admin=$3
language=$4
# Check if admin exists
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
if [[ ! $? -eq 0 ]]; then
echo "Wrong admin"
exit 1
fi
# Add settings to YunoHost
sudo yunohost app setting leed admin -v $admin
sudo yunohost app setting leed language -v $language
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a leed
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')
# Use 'leed' as database name and user
db_user=leed
# Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd
sudo yunohost app setting leed mysqlpwd -v $db_pwd
# Create leed user
sudo useradd -d /var/www/leed leed
# Copy files to right place
final_path=/var/www/leed
suko mkdir -p $final_path
sudo cp -a ../sources/* $final_path
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/leed.conf
sudo chown -hR leed:www-data $final_path
sudo chown leed:www-data /home/yunohost.app/leed
sudo chmod 755 /home/yunohost.app
# Change variables in Leed configuration
sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/leed.conf
sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/leed.conf
# Leed installation via curl
echo "127.0.0.1 $domain #yunoleed" | sudo tee -a /etc/hosts
sleep 1
curl -kL -X POST https://$domain$path/install.php --data "install_changeLngLeed=fr&root=$domain$path&mysqlHost=localhost&mysqlLogin=$db_login&mysqlMdp=$db_pwd&mysqlBase=$db_user&mysqlPrefix=leed_&login=$admin&password=$db_pwd" > /dev/null 2>&1
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf