1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hubzilla_ynh.git synced 2024-09-03 19:26:21 +02:00

Initial commit to update the base

This commit is contained in:
polytan02 2017-02-15 16:53:40 +00:00
parent 6a7eb5d6d7
commit 580ff3aa1b

View file

@ -1,71 +1,82 @@
#!/bin/bash #!/bin/bash
#set -eu source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
CLEAN_SETUP () {
# Nettoyage des résidus d'installation non pris en charge par le script remove.
# Pas de nettoyage supplémentaire nécessaire ici...
echo ""
}
TRAP_ON # Active trap pour arrêter le script si une erreur est détectée.
# Retrieve arguments # Retrieve arguments
domain=$1 app=$YNH_APP_INSTANCE_NAME
admin=$2
email=$3
upload=$4
app="hubzilla" domain=$YNH_APP_ARG_DOMAIN
path="/" path=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
email=$YNH_APP_ARG_EMAIL
upload=$YNH_APP_ARG_UPLOAD
# Source app helpers # Source app helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Check user parameter # Vérifie que les variables ne sont pas vides.
ynh_user_exists "$admin" \ CHECK_VAR "$app" "app name not set"
|| ynh_die "The chosen admin user does not exist."
ynh_app_setting_set $app admin_user $admin
CHECK_USER "$admin" # Vérifie la validité de l'user admin
# Check destination directory CHECK_PATH # Vérifie et corrige la syntaxe du path.
final_path="/var/www/$app" CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
[[ -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" # Créer le repertoire de destination et stocke son emplacement.
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
sudo mkdir "$final_path"
ynh_app_setting_set $app final_path $final_path
# Check domain/path availability # Enregistre les infos dans la config YunoHost
sudo yunohost app checkurl "${domain}${path}" -a "$app" \ ynh_app_setting_set $app domain $domain
|| ynh_die "The path ${domain}${path} is not available for app installation." ynh_app_setting_set $app path $path
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app admin $email
ynh_app_setting_set $app admin $upload
# Install dependencies # Install dependencies
sudo apt-get update sudo apt-get update
sudo apt-get install -y -qq php5-cli php5-imagick php5-gd php5-mcrypt sudo apt-get install -y -qq php5-cli php5-imagick php5-gd php5-mcrypt
# Use 'hubzilla' as database name and user # Create db
#GENERATE_DB $app # Créer une base de données et un utilisateur dédié au nom de l'app.
#Password is stored like that in the GENERATE_DB function : ynh_app_setting_set $app mysqlpwd $db_pwd
db_user=$app db_user=$app
db_name=$app db_user=${db_user//-/_} # mariadb ne supporte pas les - dans les noms de base de données. Ils sont donc remplacé par des _
# Génère un mot de passe aléatoire.
# Generate random password # db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20)
dbpass=$(ynh_string_random) db_pwd=$(ynh_string_random)
CHECK_VAR "$db_pwd" "db_pwd empty"
# Initialize database and store mysql password for upgrade # Utilise '$app' comme nom d'utilisateur et de base de donnée
sudo yunohost app initdb $db_user -p $dbpass # Initialise la base de donnée et stocke le mot de passe mysql.
sudo yunohost app setting $app mysqlpwd -v $dbpass ynh_mysql_create_db "$db_user" "$db_user" $db_pwd
ynh_app_setting_set $app db_pwd $db_pwd
#ynh_app_setting_set "$app" mysqlpwd "$dbpass" ynh_app_setting_set $app db_user $db_user
# Copy source files # Copy source files
sudo mkdir -p $final_path # A revoir
sudo rsync -va ../sources/ $final_path/ sudo rsync -va ../sources/ $final_path/
sudo mkdir -p "$final_path/store/[data]/smarty3" sudo mkdir -p "$final_path/store/[data]/smarty3"
sudo chmod -R 777 $final_path/store sudo chmod -R 777 $final_path/store
# Import database schema # Import database schema
sudo mysql -u$db_user -p$dbpass $db_name < $final_path/install/schema_mysql.sql sudo mysql -u$db_user -p$db_pwd $db_user < $final_path/install/schema_mysql.sql
# Copy the template install/htconfig.sample.php to .htconfig.php # Copy the template install/htconfig.sample.php to .htconfig.php
sudo cp $final_path/install/htconfig.sample.php $final_path/.htconfig.php sudo cp $final_path/install/htconfig.sample.php $final_path/.htconfig.php
# Use sed to add the database information to .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/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php
sudo sed -i "s/mysqlpassword/$dbpass/g" $final_path/.htconfig.php sudo sed -i "s/mysqlpassword/$db_pwd/g" $final_path/.htconfig.php
sudo sed -i "s/mysqlusername/$db_user/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/mysqldatabasename/$db_user/g" $final_path/.htconfig.php
sudo sed -i "s/mysite.example/$domain/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/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 sudo sed -i "s/ADMIN_EMAIL_REPLACE/$email/g" $final_path/.htconfig.php
@ -79,19 +90,19 @@ 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 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 # Modify php.ini to allow exec() function and increase the upload size limits
# A revoir completement
sudo sed -i 's/,pcntl_exec//g' /etc/php5/fpm/php.ini 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/^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/^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 sudo sed -i 's/^max_file_uploads =.*$/max_file_uploads = 50/' /etc/php5/fpm/php.ini
# Set SSOwat rules # Enable api for client and make app public
ynh_app_setting_set "$app" skipped_uris "/" ynh_app_setting_set $app skipped_uris "/"
# Reload services # Reload services
sudo service php5-fpm restart || true sudo service php5-fpm restart || true
sudo service nginx reload || true sudo service nginx reload || true
# Set up poller # Set up poller
sed -i "s@YNH_WWW_PATH@$final_path@g" ../conf/poller-cron sed -i "s@YNH_WWW_PATH@$final_path@g" ../conf/poller-cron
sudo cp ../conf/poller-cron /etc/cron.d/$app sudo cp ../conf/poller-cron /etc/cron.d/$app