Last active
January 31, 2018 14:07
-
-
Save kstefanini/53cdade91afd18f76ee3954a40c06190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
## Pour mettre à jour le thème wordpress (https://github.com/telabotanica/wp-theme-telabotanica/) | |
## | |
## Killian, 9 mars 2017 | |
dossier_env_test="/home/beta/www/test/wp-content/themes/telabotanica" | |
dossier_env_preprod="/home/beta/www/preprod/wp-content/themes/telabotanica" | |
fetch="git fetch origin" | |
checkout="git checkout --force origin/master" | |
composer="composer install" | |
npm_install="npm install" | |
build="npm run build" | |
if [[ $EUID -eq 0 ]]; then | |
echo "Ne lance pas ce machin en root, ça va foirer toutes les permissions !" 1>&2 | |
exit 1 | |
fi | |
# Quitte le script en affichant le message d'erreur paramétré | |
function Erreur { | |
[[ -n $1 ]] && echo -e "\e[91mERREUR \e[0m: $1" # affiche $1 si renseigné (non vide et non zéro) | |
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell | |
} | |
# Exécute une commande, affiche un message d'échec en cas d'erreur en renvoyant sur Erreur | |
function Execute { | |
echo | |
echo | |
echo -e "\e[93mEXÉCUTION DE \e[92m$1 \e[0m" | |
$1 | |
if [[ ! $? -eq 0 ]]; then | |
echo | |
Erreur "Échec lors de l'exécution de \e[92m$1 \e[0m" | |
fi | |
} | |
function main { | |
[[ -z "$1" ]] && Erreur "Il faut un paramètre, que je sache où aller, test, preprod, ... ? Merci :)" | |
if [[ "test" = "$1" ]]; then | |
Execute "cd $dossier_env_test" | |
elif [[ "preprod" = "$1" ]]; then | |
Execute "cd $dossier_env_preprod" | |
else | |
Erreur "Ça n'éxiste pas ça. C'est soit \e[95mtest\e[0m, soit \e[95mpreprod\e[0m" | |
exit 0 | |
fi | |
Execute "$fetch" | |
Execute "$checkout" | |
Execute "$composer" | |
Execute "$npm_install" | |
Execute "$build" | |
} | |
main $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment