Big Bang
commit
51f0f5458d
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /usr/share/bash-completion/completions/docker
|
||||||
|
|
||||||
|
_dc() {
|
||||||
|
((COMP_CWORD+=3))
|
||||||
|
COMP_WORDS=( docker compose -f /etc/docker/docker-compose.yml "${COMP_WORDS[@]:1}" )
|
||||||
|
_docker
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
alias dc="sudo docker compose -f /etc/docker/docker-compose.yml"
|
||||||
|
|
||||||
|
complete -F _dc dc
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ez() {
|
||||||
|
zone="$1"
|
||||||
|
file="/etc/bind/dyn/$zone.zone"
|
||||||
|
|
||||||
|
if [ -z "$zone" ]; then
|
||||||
|
echo "Usage: edit_zone zone" 2>&1
|
||||||
|
return 1
|
||||||
|
elif [ ! -e "$file" ]; then
|
||||||
|
echo "zone $zone doesnt exist!" 2>&1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
dynamic=0
|
||||||
|
if rndc zonestatus "$zone" | grep -q "dynamic: yes"; then
|
||||||
|
dynamic=1
|
||||||
|
rndc sync -clean "$zone" || return $?
|
||||||
|
rndc freeze "$zone" || return $?
|
||||||
|
echo "zone $zone frozen" 2>&1
|
||||||
|
fi
|
||||||
|
sudoedit "$file"
|
||||||
|
if [ $dynamic = 1 ]; then
|
||||||
|
rndc thaw "$zone" || return $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_ez() {
|
||||||
|
if [[ "$COMP_CWORD" -eq 1 ]]; then
|
||||||
|
COMPREPLY=($(cd "/etc/bind/dyn/*.zone" && compgen -f "${COMP_WORDS[1]}"))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _ez ez
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
site() {
|
||||||
|
command="$1"
|
||||||
|
site="$2"
|
||||||
|
file="/etc/nginx/sites-available/$site"
|
||||||
|
link="/etc/nginx/sites-enabled/$site"
|
||||||
|
|
||||||
|
if [ -z "$site" ]; then
|
||||||
|
echo "Usage: site <edit/enable/disable> name" 2>&1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$command" in
|
||||||
|
create) sudo touch "$file"; return;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ ! -e "$file" ]; then
|
||||||
|
echo "Site $site doesnt exist!" 2>&1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$command" in
|
||||||
|
delete) sudo rm "$file" "$link";;
|
||||||
|
edit) sudoedit "$file";;
|
||||||
|
copy) sudo cp "$file" "/etc/nginx/sites-available/$3";;
|
||||||
|
enable)
|
||||||
|
if [ ! -e "$link" ]; then
|
||||||
|
sudo ln -s "../sites-available/$site" "$link"
|
||||||
|
fi;;
|
||||||
|
disable)
|
||||||
|
if [ -e "$link" ]; then
|
||||||
|
sudo rm "$link"
|
||||||
|
fi;;
|
||||||
|
*)
|
||||||
|
echo "Unknown command $command" 2>&1
|
||||||
|
return 1;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_site() {
|
||||||
|
if [[ "$COMP_CWORD" -eq 1 ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "create edit delete copy enable disable" -- "${COMP_WORDS[1]}"))
|
||||||
|
elif [[ "$COMP_CWORD" -eq 2 ]]; then
|
||||||
|
case "${COMP_WORDS[1]}" in
|
||||||
|
edit|enable|delete|copy) dir=sites-available;;
|
||||||
|
disable) dir=sites-enabled;;
|
||||||
|
*) return;;
|
||||||
|
esac
|
||||||
|
COMPREPLY=($(cd "/etc/nginx/$dir/" && compgen -f "${COMP_WORDS[2]}"))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _site site
|
||||||
Loading…
Reference in New Issue