#!/bin/bash # Retrieve arguments domain=$1 path=$2 admin_passwd=$3 # Check domain/path availability sudo yunohost app checkurl $domain$path -a wordpress 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 'wordpress' as database name and user db_user=wordpress # Initialize database and store mysql password for upgrade sudo yunohost app initdb $db_user -p $db_pwd sudo yunohost app setting wordpress mysqlpwd -v $db_pwd # Copy files to the right place final_path=/var/www/wordpress sudo mkdir -p $final_path sudo cp -a ../sources/* $final_path sudo cp ../conf/wp-config.php $final_path/wp-config.php # Change variables in Wordpress configuration sudo sed -i "s/yunouser/$db_user/g" $final_path/wp-config.php sudo sed -i "s/yunopass/$db_pwd/g" $final_path/wp-config.php sudo sed -i "s/yunobase/$db_user/g" $final_path/wp-config.php # Set permissions to roundcube directory sudo chown -R www-data: $final_path # Modify Nginx configuration file and copy it to Nginx conf directory 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/wordpress.conf #Installation Wordpress sudo dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 sudo mkswap /var/swap.1 sudo swapon /var/swap.1 dpkg -l | grep php5-cli > /dev/null 2>&1 if [ $? != 0 ]; then apt-get install php5-cli fi curl https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | bash export PATH=/home/admin/.wp-cli/bin:$PATH wp core install --url=$domain$path --title=Yunohost --admin_user=admin --admin_password=$admin_passwd --admin_email=admin@$domain --path=$final_path wp plugin activate http-authentication --path=$final_path # Reload Nginx and regenerate SSOwat conf sudo service nginx reload sudo yunohost app ssowatconf # Remove swap sudo swapoff /var/swap.1 rm -Rf /var/swap.1