Split your scripts in more files so that it is more maintanable.
#!/bin/sh
echo "----------------------------"
echo "----- Starting process -----"
echo "----------------------------"
THEME_NAME='beaver'
# Import vars
source $(dirname $0)/scripts/1-variables.sh
source $(dirname $0)/scripts/2-copy-theme.sh
echo "----------------------------"
echo "---------- End -------------"
echo "----------------------------"
- Create a folder
mkdir myAwesomeSite && cd myAwesomeSite
and switch into. - create a
wp_install.sh
- make it executable with
chmod +x wp_install.sh
- fill it with
#!/bin/bash
clear
echo "---------------------------------------------------"
echo "Warning: Enter the wanted Wordpress version"
echo "Example: 4.9.2"
echo "---------------------------------------------------"
read customVersion
stableVersion=4.9.1
lastestWp=""
finalVersion=""
wordpressPath="$( cd "$(dirname "$0")" ; pwd -P )"
if [ "$customVersion" ]; then
echo "Custom version $customVersion, understood ✓"
lastestWp="https://fr.wordpress.org/wordpress-$customVersion-fr_FR.tar.gz"
finalVersion=$customVersion
else
echo "No custom version, taking stable version !"
lastestWp="https://fr.wordpress.org/wordpress-$stableVersion-fr_FR.tar.gz"
finalVersion=$stableVersion
fi
function _clean {
read -p "Do you approve a hard clean ? (will delete everything around the script), continue ? (y/n)" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Cleaning repository, please wait..."
find . -not -name 'wp_install.sh' -delete
echo "Repository Cleaned !"
fi
}
function getWordpress {
echo "Looking to the $1 version of Wordpress"
COMPRESSED_WP=wordpress-$1-fr_FR.tar.gz
echo "Checking if $COMPRESSED_WP exists in current folder"
if [ -f $COMPRESSED_WP ]; then
echo "$COMPRESSED_WP exists"
echo "Extracting $COMPRESSED_WP, please wait.."
tar -xf $COMPRESSED_WP
else
echo "$COMPRESSED_WP does not exists"
echo "Downloading the v$finalVersion version of Wordpress"
wget $lastestWp >/dev/null || curl -O $lastestWp .
echo "Extracting $COMPRESSED_WP, please wait.."
tar -xf $COMPRESSED_WP
fi
echo "Removing wordpress folder"
cp -R wordpress/* . && rm -rf wordpress
echo "** Wordpress installed ! ✅ **"
echo "Check it out on $wordpressPath"
}
_clean
getWordpress $finalVersion
echo "---- Script under GNU GPL is written by Ugo Arzur ---"
- launch it with
./wp_install.sh
source stackoverwflow
source Get script path
This Little Script is Distributed by www.coding101.in and written by Akash S. Patel.
-
Create a file
wp_permissions.sh
in your wordpress root directory. -
Make it executable with
chmod +x wp_permissions.sh
. -
Run the
pwd
to see the absolute path. -
Run the script with
./wp_permissions.sh
-
Follow the instructions entering the absolute path and the recommended permissions by wordpress.
echo "---------------------------------------------------"
echo "Warning: Enter Your Wordpress path in proper format as Example shown below:"
echo "Example: var/www/html/wordpress/"
echo "---------------------------------------------------"
read path
echo "enter permission type d (default is 755)"
read perm1
echo "enter permission type f (default is 644)"
read perm2
sudo chown -R www-data:www-data $path
sudo find /$path -type d -exec chmod $perm1 {} \;
sudo find /$path -type f -exec chmod $perm2 {} \;
clear
echo "Done ! Now check wordpress upload/download of theme/plugin !"
echo "---------------------------------------------------"
echo "This Little Script is Distributed by www.coding101.in"
echo "Written by Akash S. Patel"
echo "---------------------------------------------------"
ps : Here another intresting resource even if I could not managed to use it.
Add the following line into wp-config.php
:
define('FS_METHOD', 'direct');