add firewall rules with a rules handler, setup command fix and rust server
This commit is contained in:
parent
fb7b388c8e
commit
01e4c835b2
5 changed files with 153 additions and 23 deletions
96
man
96
man
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
PROJECT_NAME=${PROJECT_NAME:-neo}
|
||||
BLACKLIST=""
|
||||
LIST=docker-compose.*.yml
|
||||
|
||||
alias dc="docker-compose -p $PROJECT_NAME"
|
||||
# alias dc="echo docker-compose -p $PROJECT_NAME"
|
||||
|
@ -11,28 +11,18 @@ 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"
|
||||
fopts=""
|
||||
for f in $LIST; do
|
||||
fopts="$fopts -f $f"
|
||||
done
|
||||
dc $file_opts $@
|
||||
dc $fopts $*
|
||||
}
|
||||
|
||||
includechain=0
|
||||
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"
|
||||
|
@ -42,13 +32,21 @@ handleFallthrough() {
|
|||
[ "$answer" = "yes" ] && sudo rm -rf /srv/$1 || fatal "cancelled"
|
||||
;;
|
||||
|
||||
-b)
|
||||
BLACKLIST="$BLACKLIST $1"; shift
|
||||
-i) #include
|
||||
if [ $includechain -eq 0 ]; then
|
||||
LIST="docker-compose.$1.yml"
|
||||
includechain=1
|
||||
else
|
||||
LIST="$LIST docker-compose.$1.yml"
|
||||
fi
|
||||
shift
|
||||
handleFallthrough $@
|
||||
;;
|
||||
;;
|
||||
|
||||
setup-all)
|
||||
sh utils/setup.sh
|
||||
-x) #exclude
|
||||
LIST=$(echo $LIST | sed "s/docker-compose.$1.yml//")
|
||||
shift
|
||||
handleFallthrough $@
|
||||
;;
|
||||
|
||||
make:*)
|
||||
|
@ -71,9 +69,65 @@ handleFallthrough() {
|
|||
esac
|
||||
;;
|
||||
|
||||
setup:*|s:*)
|
||||
WHAT=`echo $cmd | cut -c8-`
|
||||
case $WHAT in
|
||||
ports) sudo setup-ports.sh up ;;
|
||||
def) sudo setup.sh ;;
|
||||
all|a)
|
||||
sudo setup.sh
|
||||
sudo setup-ports.sh up
|
||||
;;
|
||||
*) fatal "not supported" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# preference
|
||||
logs) default logs --tail=20 -f $@ ;;
|
||||
up) default up -d $@ ;;
|
||||
upr) default up -d --remove-orphans $@ ;;
|
||||
|
||||
--help|-h)
|
||||
__() {
|
||||
colsep="$1"
|
||||
cmd="$2"
|
||||
desc="$3"
|
||||
aliases="$4"
|
||||
printf "%s %-20s %s %-64s %s %-40s %s \n" "$colsep" "$cmd" "$colsep" "$desc" "$colsep" "$aliases" "$colsep"
|
||||
}
|
||||
_hr() {
|
||||
repchar() {
|
||||
printf "%$1s" | tr " " "$2"
|
||||
}
|
||||
__ "*" ${1:-$(repchar 20 -)} ${2:-$(repchar 64 -)} ${3:-$(repchar 40 -)}
|
||||
}
|
||||
_r() {
|
||||
__ "|" "$1" "$2" "$3"
|
||||
}
|
||||
_hr
|
||||
_r $0 Description Aliases
|
||||
_hr
|
||||
_hr "Flags" " " " "
|
||||
_hr
|
||||
_r "-x" "Excludes a docker-compose file from the list." " "
|
||||
_r "-i" "Includes a docker-compose file from the list." " "
|
||||
_hr
|
||||
_hr "Commands" " " " "
|
||||
_hr
|
||||
_r "dpf" "Delete project files." "delete-project-files <name>"
|
||||
_r "setup" "Run setup script." "sh ./utils/setup.sh"
|
||||
_r "make:dc <name>" "Make docker-compose file." "make:docker-compose <name>"
|
||||
_r "make:backup <name>" "Make backup file." "tar cvf <name>.tar.gz /srv"
|
||||
_hr
|
||||
_hr "Commands/aliases" "(shortcuts)" " "
|
||||
_hr
|
||||
_r "up" "Bring up services. (-d)" "$0 default up -d"
|
||||
_r "upr" "Bring up services and remove orphans." "$0 default up -d --remove-orphans"
|
||||
_r "logs" "View logs and follow with a tail of 20." "$0 default logs --tail=20 -f"
|
||||
_hr
|
||||
_r "default" "fallback to the main docker-compose command with fileopts." "docker-compose"
|
||||
_hr
|
||||
;;
|
||||
|
||||
default) default $@ ;;
|
||||
*|'') default $cmd $@ ;;
|
||||
|
|
Reference in a new issue