1
1
Fork 0

push work from laptop

This commit is contained in:
david 2020-06-22 09:19:15 +02:00
parent 8aee50adf5
commit eb79cd4e42
2 changed files with 129 additions and 36 deletions

View File

@ -2,6 +2,7 @@
_My personal collection of handy scripts. mostly bash._
## setup_zsh.sh
One-line installer for zsh, oh-my-zsh and various zsh plugins.
@ -11,20 +12,7 @@ curl -fsSL https://socialg.it/david/scripts/raw/master/setup_zsh.sh | bash
It is still highly experimental and will probably fail on your system.
## mc.sh
A minecraft server hosting helper script.
## sconfig.sh
```
usage: mc option <server>
Servers:
[✗] minecraft_server_1
Options:
help Print usage message
status Print server(s)
start <server> Start server instance
stop <server> Stop server instance
console <server> Connect to server console
```
This is a script to help you configure various aspects of a linux server.

View File

@ -19,38 +19,143 @@
## setup snmpd
##
## usage: sconfig
##
## changelog: 2020-06-22 first draft of a working menu
## 2020-06-21 started development of v0.1
#TODO: merge content of prep_ubuntu_server.sh in here
# **** start of script ****
## functions
get-users()
{
pass
}
### check for superuser privileges
amiroot() { if [ $(whoami) != "root" ]; then return 1; fi }
add-user()
{
pass
}
dis-user()
{
pass
}
print-screen()
{
### header and footer output
header() {
clear
echo "============================================"
echo " sconfig"
echo "============================================"
local cols=$(tput cols); local char="="
local i=0; while [ $i != $((cols)) ]; do local chars="$chars$char"; i=$((i+1)); done
echo $chars; echo "Server configuration"; echo -e "$chars\n"
}
## run script
print-screen
footer() {
local lines=$(tput lines)
local i=5; while [ $i != $((lines-$1)) ]; do echo ""; i=$((i+1)); done
local option=""; read -n 1 -p "Enter number to select an option: " option
if [[ $option =~ ^[1-9]+$ ]]; then return $option; fi
}
menu() {
header
local lines=$(tput lines)
for i in $(seq 1 $#); do
echo "$i) ${!i}"
done
footer $i
}
### ask for confirmation
confirm() {
header
echo "Are you sure?"
echo "1) Yes"
echo "2) No"
footer 3
if [ $? -eq 1 ]; then return 0; else return 1; fi
}
### main menu
mainmenu() {
header
echo "1) Install operating system updates"
echo
echo "3) Start a shell session"
echo "4) Restart server"
echo "5) Shutdown server"
echo "6) Logout"
echo
footer 7
case $? in
1)
header
echo 1; sleep 1
;;
2)
header
echo 2; sleep 1
;;
3)
header
echo "Executing $SHELL"; sleep 1; clear
$SHELL
;;
4)
if confirm; then
header
echo "Rebooting server"; sleep 1
#sudo shutdown -r -t now
fi
;;
5)
if confirm; then
header
echo "Shutting down server"; sleep 1
#sudo shutdown -h -t now
fi
;;
6)
header
echo "Logging out"; sleep 1
exit 0
;;
*)
header
echo "Unknown option"; sleep 1
;;
esac
}
update() {
systems="ubuntu arch solus raspbian antergos"
issue="$(cat /etc/issue)"
for item in $systems; do
echo $issue | grep -i $item >> /dev/null
if [ $? -eq 0 ]; then
system=$item
fi
done
case $system in
ubuntu|debian|raspbian)
echo "Updating Ubuntu/Debian.."
sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y
;;
arch|antergos)
echo "Updating Arch Linux.."
sudo pacman -Syu
;;
?)
echo "error: unknown system."
return 1
;;
esac
if [ $? -ne 0 ]; then
echo "error: something went wrong."
return 1
fi
}
## start loop
menu "Install system upgrades" \
"Reboot server" \
"Shutdown server" \
"Logout"
#while true; do mainmenu; done
exit 0
# **** end of script ****