mirror of
https://github.com/YunoHost-Apps/friendica_ynh.git
synced 2024-09-03 18:36:14 +02:00
113 lines
3.8 KiB
Bash
113 lines
3.8 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
timezone=$(cat /etc/timezone)
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
|
|
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=5
|
|
|
|
git config --system --add safe.directory $install_dir
|
|
|
|
# 1 - Clone stable repo
|
|
git clone --quiet https://github.com/friendica/friendica.git -b stable "$install_dir"
|
|
# Reset branch to the level of update we needed
|
|
pushd "$install_dir"
|
|
git reset --hard --quiet $version_commit
|
|
popd
|
|
|
|
# Copy .htaccess-dist to ..htaccess
|
|
cp -f "$install_dir/.htaccess-dist" "$install_dir/.htaccess"
|
|
|
|
# 2 - Clone addons repo
|
|
git clone --quiet https://github.com/friendica/friendica-addons.git -b stable "$install_dir/addon"
|
|
# Reset addons branch to the level of update we needed
|
|
pushd "$install_dir/addon"
|
|
git reset --hard --quiet $addons_version_commit
|
|
popd
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
|
|
# Create a dedicated nginx config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding the LDAP Auth addon configuration file..." --weight=1
|
|
|
|
# LDAP addon config
|
|
ynh_add_config --template="../conf/addon.config.php" --destination="$install_dir/config/addon.config.php"
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring PHP_FPM..." --weight=4
|
|
|
|
# Create a dedicated PHP-FPM configy
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
|
|
|
# 3 - some extra folders
|
|
mkdir -p "$install_dir/view/smarty3"
|
|
chmod -R 775 "$install_dir/view/smarty3"
|
|
|
|
#=================================================
|
|
# SETUP A CRON
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up the cron job..." --weight=1
|
|
|
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|
chown root: "/etc/cron.d/$app"
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# INSTALL FRIENDICA
|
|
#=================================================
|
|
ynh_script_progression --message="Install Friendica..." --weight=1
|
|
|
|
pushd "$install_dir"
|
|
# Import Composer dependencies
|
|
ynh_exec_as "$app" php$phpversion bin/composer.phar install --no-dev --quiet
|
|
|
|
# Install application
|
|
ynh_exec_as "$app" php$phpversion bin/console.php autoinstall\
|
|
--dbhost "localhost" --dbdata "$db_name" --dbuser "$db_user" --dbpass "$db_pwd"\
|
|
--admin "$email" --tz "$timezone" --lang "$language" --url "https://$domain$path"
|
|
|
|
# Enable LDAP Auth addon
|
|
ynh_exec_as "$app" php$phpversion bin/console.php addon enable ldapauth
|
|
popd
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|