This repository has been archived on 2023-05-02. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
neo/man
2022-12-04 22:30:49 +01:00

82 lines
No EOL
2 KiB
Bash
Executable file

#!/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 $@