#!/bin/bash #set -eu # Retrieve arguments domain=$1 admin=$2 email=$3 upload=$4 app="hubzilla" path="/" # Source app helpers source /usr/share/yunohost/helpers # Check user parameter ynh_user_exists "$admin" \ || ynh_die "The chosen admin user does not exist." ynh_app_setting_set $app admin_user $admin # Check destination directory final_path="/var/www/$app" [[ -d $final_path ]] && ynh_die \ "The destination directory '$DESTDIR' already exists.\ You should safely delete it before installing this app." sudo yunohost app setting $app is_public -v "Yes" # Check domain/path availability sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "The path ${domain}${path} is not available for app installation." # Install dependencies sudo apt-get update sudo apt-get install -y -qq php5-cli php5-imagick php5-gd php5-mcrypt # Use 'hubzilla' as database name and user db_user=$app db_name=$app # Generate random password dbpass=$(ynh_string_random) # Initialize database and store mysql password for upgrade sudo yunohost app initdb $db_user -p $dbpass sudo yunohost app setting $app mysqlpwd -v $dbpass #ynh_app_setting_set "$app" mysqlpwd "$dbpass" # Copy source files sudo mkdir -p $final_path sudo rsync -va ../sources/ $final_path/ sudo mkdir -p "$final_path/store/[data]/smarty3" sudo chmod -R 777 $final_path/store # Import database schema sudo mysql -u$db_user -p$dbpass $db_name < $final_path/install/schema_mysql.sql # Copy the template install/htconfig.sample.php to .htconfig.php sudo cp $final_path/install/htconfig.sample.php $final_path/.htconfig.php # Use sed to add the database information to .htconfig.php sudo sed -i "s/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php sudo sed -i "s/mysqlpassword/$dbpass/g" $final_path/.htconfig.php sudo sed -i "s/mysqlusername/$db_user/g" $final_path/.htconfig.php sudo sed -i "s/mysqldatabasename/$db_name/g" $final_path/.htconfig.php sudo sed -i "s/mysite.example/$domain/g" $final_path/.htconfig.php sudo sed -i "s/if the auto install failed, put a unique random string here/$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)/g" $final_path/.htconfig.php sudo sed -i "s/ADMIN_EMAIL_REPLACE/$email/g" $final_path/.htconfig.php # Set www-data to owner sudo chown -R www-data: $final_path # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Modify php.ini to allow exec() function and increase the upload size limits sudo sed -i 's/,pcntl_exec//g' /etc/php5/fpm/php.ini sudo sed -i 's/^post_max_size =.*$/post_max_size = $upload/' /etc/php5/fpm/php.ini sudo sed -i 's/^upload_max_filesize =.*$/upload_max_filesize = $upload/' /etc/php5/fpm/php.ini sudo sed -i 's/^max_file_uploads =.*$/max_file_uploads = 50/' /etc/php5/fpm/php.ini # Set SSOwat rules ynh_app_setting_set "$app" skipped_uris "/" # Reload services sudo service php5-fpm restart || true sudo service nginx reload || true # Set up poller sed -i "s@YNH_WWW_PATH@$final_path@g" ../conf/poller-cron sudo cp ../conf/poller-cron /etc/cron.d/$app