segregation+tool
This commit is contained in:
parent
4bff577418
commit
45a751e736
7 changed files with 302 additions and 24 deletions
82
man
Executable file
82
man
Executable file
|
@ -0,0 +1,82 @@
|
|||
#!/bin/sh
|
||||
|
||||
PROJECT_NAME=${PROJECT_NAME:-neo}
|
||||
BLACKLIST=""
|
||||
|
||||
alias dc="docker-compose -p $PROJECT_NAME"
|
||||
# alias dc="echo docker-compose -p $PROJECT_NAME"
|
||||
|
||||
fatal() {
|
||||
echo "FATAL: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
only() {
|
||||
FILE="docker-compose.$1.yml"; shift
|
||||
default() {
|
||||
dc -f $FILE $@
|
||||
}
|
||||
handleFallthrough $@
|
||||
}
|
||||
|
||||
default() {
|
||||
file_opts=""
|
||||
for f in docker-compose.*.yml; do
|
||||
# echo $BLACKLIST | grep -q $f && continue
|
||||
echo $BLACKLIST | grep -q $(echo $f | cut -d. -f2) && continue
|
||||
file_opts="$file_opts -f $f"
|
||||
done
|
||||
dc $file_opts $@
|
||||
}
|
||||
|
||||
handleFallthrough() {
|
||||
cmd=${1:-}; shift
|
||||
case $cmd in
|
||||
only) only $@ ;;
|
||||
delete-project-files|dpf)
|
||||
[ -n "$1" ] || fatal "no directory specified"
|
||||
[ -d /srv/$1 ] || fatal "directory doesn't exist"
|
||||
ls /srv/$1
|
||||
printf "Are you sure? (yes/no) [no]: "
|
||||
read answer
|
||||
[ "$answer" = "yes" ] && sudo rm -rf /srv/$1 || fatal "cancelled"
|
||||
;;
|
||||
|
||||
-b)
|
||||
BLACKLIST="$BLACKLIST $1"; shift
|
||||
handleFallthrough $@
|
||||
;;
|
||||
|
||||
setup-all)
|
||||
sh utils/setup.sh
|
||||
;;
|
||||
|
||||
make:*)
|
||||
WHAT=`echo $cmd | cut -c6-`
|
||||
case $WHAT in
|
||||
dc|docker-compose)
|
||||
[ -n "$1" ] || fatal "no name specified"
|
||||
FILE="docker-compose.$1.yml"
|
||||
[ -f $FILE ] && fatal "file exists"
|
||||
echo -e "version: '2.2'\n" > $FILE
|
||||
echo -e "services: \n" >> $FILE
|
||||
;;
|
||||
backup)
|
||||
[ -n "$1" ] || fatal "no name specified"
|
||||
FILE="$1.tar.gz"
|
||||
[ -f $FILE ] && fatal "file exists"
|
||||
tar cvf $FILE /srv .
|
||||
;;
|
||||
*) fatal "not supported" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# preference
|
||||
logs) default logs --tail=20 -f $@ ;;
|
||||
up) default up -d $@ ;;
|
||||
|
||||
default|*|'') default $cmd $@ ;;
|
||||
esac
|
||||
}
|
||||
|
||||
handleFallthrough $@
|
Reference in a new issue