Last active
December 25, 2015 00:58
-
-
Save deiu/6891239 to your computer and use it in GitHub Desktop.
RWW.IO Web app deployer
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/sh | |
# RWW.IO Web app deployer. Simply run `sh deploy.sh` inside your Web app dir and follow the steps. | |
CERTCMD="" | |
# get target URI | |
read -p "Please provide the URI of the target dir (ex: http://example.org/apps/myapp/): " HOST | |
if [ "$HOST" = "" ] | |
then | |
read -p "Please provide the URI of the target dir (ex: http://example.org/apps/myapp/): " HOST | |
fi | |
# get certificate path | |
read -p "Please provide the path containing the name of your certificate file, in PEM format (leave blank if none): " CERT | |
# add trailing slash to target dir if not present | |
if [ `echo "$HOST" | grep "[^/]$"` ]; then HOST="$HOST/"; fi | |
# add cert arguments to the curl command | |
if [ "$CERT" != "" ]; then CERTCMD="-E $CERT";fi | |
# create the dir structure (using MKCOL to increase interoperabilty) | |
for dir in `find . -mindepth 1 -type d ! -path ./.git\* | sed "s|^\./||"`: | |
do | |
echo "Creating dir: $dir" | |
curl -X 'MKCOL' $CERTCMD $HOST$dir | |
done | |
# upload the files now | |
for file in `find . -mindepth 1 -type f ! -path ./.git\* | sed "s|^\./||"`: | |
do | |
# remove trailing ":" (weird) | |
if [ ! `echo "$file" | grep "[^:]$"` ]; then file="${file%?}";fi | |
echo "Uploading file: $HOST$file" | |
curl --upload-file $file $CERTCMD $HOST$file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment