Skip to content

Instantly share code, notes, and snippets.

@Cezarion
Last active August 29, 2015 14:07
Show Gist options
  • Save Cezarion/6f8990e01a41c68b7856 to your computer and use it in GitHub Desktop.
Save Cezarion/6f8990e01a41c68b7856 to your computer and use it in GitHub Desktop.
Init a git repository for wordpress
#!/bin/sh
if [ -e .gitignore ]; then
echo "Il y a déjà un fichier .gitignore. Bye" >&2
exit 1
else
echo "Ecriture du fichier .gitignore" >&2
fi
cat > .gitignore <<EOF
## -----------------------------------------
## OS
## -----------------------------------------
# -----------------------------------------
# OSX
# -----------------------------------------
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows
# -----------------------------------------
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
## ------------------------------
## Composer
## ------------------------------
composer.phar
vendor/
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
## ------------------------------
## Wordpress
## ------------------------------
*.log
.htaccess
sitemap.xml
sitemap.xml.gz
wp-config.php
wp-content/advanced-cache.php
wp-content/backup-db/
wp-content/backups/
wp-content/blogs.dir/
wp-content/cache/
wp-content/upgrade/
wp-content/uploads/
wp-content/wp-cache-config.php
wp-content/themes/twenty*
## Finaly : this file :
wp-git-init.sh
EOF
if [ -e .gitignore ]; then
echo "Fichier gitignore créé..." >&2
else
echo "Ooooops pas possible de crééer le fichier gitignore... Bye" >&2
exit 1
fi
# Création du repo
if [ -d .git ]; then
echo "Il y a déjà un repo .git" >&2
exit 1
fi
git init >&2
echo $2
# Ajout du remote
read -p "Renseignez le repo distant : " url
git remote add origin $url >&2
echo $2
# Liste des fichiers
git status >&2
echo $2
echo "Ajouter les fichiers ci-dessus au repo (y/n) "
read what
if [ "$what" = "y" ] || [ "$what" = "yes" ]; then
git add . >&2
echo $2
else
echo "A vous d'ajouter les fichiers. Bye... "
exit 1
fi
read -p "Commiter les changements ? (y/n) " what
if [ "$what" = "y" ] || [ "$what" = "yes" ]; then
read -p "Message du commit : " msg
git commit -am '$msg' >&2
echo $2
else
echo "Bye... "
exit 1
fi
read -p "Proteger les fichiers sensibles de wordpress ? (y/n) " yepnop
if [ "$yepnop" = "y" ] || [ "$yepnop" = "yes" ]; then
cat <<EOT >> .htaccess
# ---------------- WP FILES ------------------
# Protect wp sensible files
<FilesMatch "^(wp-config\.php|php\.ini|php5\.ini|readme\.html|bb-config\.php)">
Order Allow,Deny
Deny from all
</FilesMatch>
# End protect sensible files
EOT
fi
echo 'Bye...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment