1
0
Fork 0
Jessa 2024-06-01 10:31:32 -07:00
commit e4934af0ca
4 changed files with 108 additions and 0 deletions

7
LICENSE Normal file
View File

@ -0,0 +1,7 @@
Copyright (c) 2024 jessa0
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

14
dc.sh Normal file
View File

@ -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

33
ez.sh Normal file
View File

@ -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

54
site.sh Normal file
View File

@ -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