File: new_webmachine.sh

package info (click to toggle)
rabbitmq-server 3.3.5-1.1
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 12,004 kB
  • sloc: erlang: 78,203; python: 3,187; xml: 2,843; makefile: 903; sh: 831; java: 660; perl: 64; ruby: 63
file content (39 lines) | stat: -rwxr-xr-x 797 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash

SCRIPT=${0##*/}
NAME=$1
DESTDIR=$2

usage() {
    echo "usage: new_webmachine.sh name [destdir]"
}

if [ -z $NAME ] || [[ $NAME =~ ^[\.\~\/] ]]; then
    usage
    exit 1
fi

erl -noshell -eval 'halt(if is_atom('"$NAME"') -> 0; true -> 1 end).'
if [[ $? -ne 0 ]]; then
    echo $SCRIPT: \""$NAME"\" is not allowed as a project name
    echo '  The project name must begin with a lowercase letter and'
    echo '  contain only alphanumeric characters and underscores.'
    usage
    exit 1
fi

if [ -z $DESTDIR ]; then
    DESTDIR="."
elif [[ $DESTDIR =~ /${NAME}$ ]]; then
    DESTDIR=${DESTDIR%/*}
fi

if [ ! -e $DESTDIR ]; then
    $(mkdir -p $DESTDIR)
fi

ABSDEST=$(cd $DESTDIR && pwd)

cd ${0%/*}/../priv

../rebar create template=wmskel appid=$NAME prefix=$ABSDEST/$NAME