mirror of
https://github.com/YunoHost-Apps/friendica_ynh.git
synced 2024-09-03 18:36:14 +02:00
89 lines
2.4 KiB
Bash
89 lines
2.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$1
|
|
path=$2
|
|
user=$3
|
|
is_public=$4
|
|
|
|
# Check user parameter
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$user\""
|
|
if [[ ! $? -eq 0 ]]; then
|
|
echo "Wrong user"
|
|
exit 1
|
|
fi
|
|
sudo yunohost app setting friendica admin_user -v $user
|
|
|
|
final_path=/var/www/friendica
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a friendica
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# Get admin mail
|
|
admin_mail=$(sudo yunohost user info $user | grep "mail:" | cut -d' ' -f2)
|
|
|
|
# Get code
|
|
version=$(cat upstream_version)
|
|
repo_url=$(cat ../conf/repo_url)
|
|
repo_url_addons=$(cat ../conf/repo_url_addons)
|
|
git clone -b "${version}" $repo_url friendica
|
|
git clone -b "master" $repo_url_addons friendica-addons
|
|
sudo mv friendica-addons friendica/addon
|
|
sudo cp -ar friendica $final_path
|
|
|
|
# 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 'friendica' as database name and user
|
|
db_user=friendica
|
|
|
|
# Initialize database and store mysql password for upgrade
|
|
sudo yunohost app initdb $db_user -p $db_pwd
|
|
sudo yunohost app setting friendica mysqlpwd -v $db_pwd
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
final_path=/var/www/friendica
|
|
|
|
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/friendica.conf
|
|
|
|
# configure friendica
|
|
|
|
sudo cp $final_path/htconfig.php $final_path/.htconfig.php
|
|
|
|
sudo sed -i "s@your.mysqlhost.com@localhost@g" $final_path/.htconfig.php
|
|
sudo sed -i "s@mysqlusername@$db_user@g" $final_path/.htconfig.php
|
|
sudo sed -i "s@mysqldatabasename@$db_user@g" $final_path/.htconfig.php
|
|
sudo sed -i "s@mysqlpassword@$db_pwd@g" $final_path/.htconfig.php
|
|
sudo sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$admin_mail';/g" $final_path/.htconfig.php
|
|
|
|
# init db
|
|
|
|
mysql -u $db_user -p$db_pwd $db_user < $final_path/database.sql
|
|
|
|
# addon config
|
|
sudo su -c "cat ../conf/conf.php >> $final_path/.htconfig.php"
|
|
|
|
# set permission
|
|
|
|
sudo chown -R www-data:www-data $final_path
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
sudo yunohost app setting friendica skipped_uris -v "/"
|
|
sudo yunohost app ssowatconf
|
|
|
|
#protect URIs
|
|
|
|
if [ $is_public = "0" ];
|
|
then
|
|
sudo yunohost app setting friendica protected_uris -v "/"
|
|
sudo yunohost app ssowatconf
|
|
fi
|