Created
November 17, 2011 13:52
-
-
Save ogorzalka/1373182 to your computer and use it in GitHub Desktop.
Project management
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 | |
REMOTESERVER="your_server" # adresse du dépôt distant | |
REMOTESERVER_USER="ssh_user" # identifiant du serveur distant | |
REMOTE_GITFOLDER="/chemin/vers/depot/nu/" # chemin du dépôt nu sur le serveur distant | |
ACTION=$1 | |
REMOTE_GITREPO="$REMOTE_GITFOLDER$PROJECTNAME.git" | |
LOCALPATH=`pwd` | |
PROJECTNAME=${PWD##*/} | |
if [ "$ACTION" == "create" ]; | |
then | |
PROJECTNAME=$2 | |
LOCALPATH="$LOCALPATH/$PROJECTNAME" | |
echo "Création du projet \"$PROJECTNAME\"" | |
echo "Création du dépot Git distant..." | |
ssh $REMOTESERVER_USER@$REMOTESERVER <<END_SCRIPT | |
mkdir "$REMOTE_GITREPO"; | |
cd "$REMOTE_GITREPO" | |
git init --bare | |
git-update-server-info | |
pwd | |
quit | |
END_SCRIPT | |
echo "Dépot distant créé !" | |
if [ ! -d "$LOCALPATH" ]; | |
then | |
mkdir "$LOCALPATH" | |
chmod 777 "$LOCALPATH" | |
cd "$LOCALPATH" | |
echo "Création du dépot Git local" | |
git init | |
git remote add origin "ssh://$REMOTESERVER_USER@$REMOTESERVER$REMOTE_GITREPO" | |
git config branch.master.remote origin | |
git config branch.master.merge refs/heads/master | |
echo "Dépot local créé !" | |
PS3='Quel outil souhaitez vous installer ?' | |
select choice in "Wordpress" "CodeIgniter" "Aucun" | |
do | |
if [ "$choice" == "Wordpress" ]; | |
then | |
echo "Installation de la dernière version de Wordpress" | |
wget http://fr.wordpress.org/latest-fr_FR.zip wordpress_latest-fr_FR.zip | |
unzip latest-fr_FR.zip | |
mv wordpress/* . | |
rm -rf wordpress | |
rm -rf latest-fr_FR.zip | |
echo "*.DS_Store | |
Thumbs.db | |
desktop.ini | |
.gitignore | |
wp-config.php" > $LOCALPATH/.gitignore | |
mkdir "$LOCALPATH/wp-content/upload" | |
chmod 777 "$LOCALPATH/wp-content/upload" | |
git add . | |
git commit -m "Installation de Wordpress" | |
echo "Installation de Wordpress terminée" | |
break | |
elif [ "$choice" == "CodeIgniter" ]; | |
then | |
echo "Installation de la dernière version de CodeIgniter" | |
wget http://codeigniter.com/download.php | |
mv download.php latest-fr_FR.zip | |
UNZIPNAME=( `unzip -l latest-fr_FR.zip | awk 'NR==4{print $4}' | sed 's/\/// '`) | |
echo $UNZIPNAME | |
unzip latest-fr_FR.zip | |
mv $UNZIPNAME/* . | |
rm -rf $UNZIPNAME | |
rm -rf latest-fr_FR.zip | |
wget https://raw.github.com/EllisLab/CodeIgniter/master/.gitignore | |
git add . | |
git commit -m "Installation de CodeIgniter" | |
echo "Installation de CodeIgniter terminée" | |
break | |
else | |
git add . | |
touch .gitignore | |
git commit -m "added .gitignore" | |
fi | |
done | |
git push --all | |
else | |
echo "Le projet existe déja. Veuillez choisir un nouveau dossier." | |
fi | |
elif [ "$ACTION" == "update" ]; | |
then | |
MSG=$2 | |
cd "$LOCALPATH" | |
echo "Mise à jour du projet \"$PROJECTNAME\"" | |
git add .gitignore | |
git commit -m "updated .gitignore" | |
until [ "$MSG" != "" ]; | |
do | |
echo "Merci de fournir un message concernant les modifications apportées au projet" | |
read MSG | |
done | |
git add . | |
git commit -m "$MSG" | |
elif [ "$ACTION" == "upload" ]; | |
then | |
MSG=$2 | |
cd "$LOCALPATH" | |
echo "Mise en ligne du projet \"$PROJECTNAME\" sur le dépot nu distant" | |
git add .gitignore | |
git commit -m "updated .gitignore" | |
if [ "$MSG" != "" ]; | |
then | |
git add . | |
git commit -m "$MSG" | |
fi | |
git push --all | |
elif [ "$ACTION" == "recover" ]; | |
then | |
PROJECTNAME=$2 | |
LOCALPATH="$LOCALPATH/$PROJECTNAME" | |
if [ ! -d "$LOCALPATH" ]; | |
then | |
mkdir "$LOCALPATH" | |
cd "$LOCALPATH" | |
git clone "ssh://$REMOTESERVER_USER@$REMOTESERVER$REMOTE_GITREPO" . | |
echo "Projet récupéré. Veuillez maintenant vérifier la configuration." | |
else | |
echo "Le projet existe déja. Déplacez le dossier vers un autre emplacement si vous souhaitez réellement recréer le projet original." | |
fi | |
git push --all | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment