1
1
Fork 0

extended update function to cleanup and autoremove

This commit is contained in:
david 2020-06-21 13:26:14 +02:00
parent b07b649c3e
commit 22d0f239f8
1 changed files with 20 additions and 41 deletions

View File

@ -6,7 +6,7 @@
set -o shwordsplit set -o shwordsplit
# **** aliases definitions **** # **** aliases ****
alias zz='source $HOME/.zshrc' alias zz='source $HOME/.zshrc'
alias {update_zsh,zu}='echo "LAST_EPOCH=0" > $ZSH_CACHE_DIR/.zsh-custom-update > $ZSH_CACHE_DIR/.zsh-update; source $HOME/.zshrc' alias {update_zsh,zu}='echo "LAST_EPOCH=0" > $ZSH_CACHE_DIR/.zsh-custom-update > $ZSH_CACHE_DIR/.zsh-update; source $HOME/.zshrc'
alias vz='vim $HOME/.zshrc && source $HOME/.zshrc' alias vz='vim $HOME/.zshrc && source $HOME/.zshrc'
@ -26,6 +26,8 @@ alias aec="sshuttle -vvr 90.146.8.233 192.168.6.0/24 90.146.8.0/26 10.9.0.0/26 1
alias home="sshuttle -vvr stargazer.socialnerds.org:2222 10.1.0.0/16" alias home="sshuttle -vvr stargazer.socialnerds.org:2222 10.1.0.0/16"
alias dmz="sshuttle -vvr 90.146.8.9 90.146.8.0/26" alias dmz="sshuttle -vvr 90.146.8.9 90.146.8.0/26"
alias c="clear" alias c="clear"
#alias cleardnscache="sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache; say DNS cache has been cleared"
alias cleardnscache="sudo killall -HUP mDNSResponder; sudo dscacheutil -flushcache; say DNS cache has been cleared"
#alias ls='ls --color=auto' #does not work on macos #alias ls='ls --color=auto' #does not work on macos
alias pacrepo='sudo reflector -l 20 -f 10 --save /etc/pacman.d/mirrorlist' alias pacrepo='sudo reflector -l 20 -f 10 --save /etc/pacman.d/mirrorlist'
@ -72,10 +74,18 @@ log() {
sleep 0.5; echo -e "[$level] ${@:2}" sleep 0.5; echo -e "[$level] ${@:2}"
} }
## setup user accounts on linux systems # setup user accounts on linux systems
# update them if existing
# ? delete them
# add authorized_keys
setup_user() { setup_user() {
if [ $1 ]; then if [ $1 ]; then
log info "setting up account for $1" log info "setting up account for $1"
#TODO: do the groups exist beforehand?
useradd -m -d /home/$1 -G "sudo sshusers docker" $1
if [ $? -ne 0 ]; then
log error "error while creating user ($1)"
fi
else else
log error "no username given" log error "no username given"
return 1 return 1
@ -83,9 +93,7 @@ setup_user() {
} }
## RDP client ## RDP client
rdp() rdp() {
{
if [ -z $1 ]; then if [ -z $1 ]; then
echo -e "server: \c" echo -e "server: \c"
read server read server
@ -121,22 +129,22 @@ rdp()
fi fi
} }
## OS Upgrade for various systems.
update() ## OS upgrade for various systems
{ update() {
systems="ubuntu arch solus raspbian antergos" systems="ubuntu arch solus raspbian antergos"
issue="$(cat /etc/issue)" issue="$(cat /etc/issue)"
for item in $systems; do for item in $systems; do
echo $issue | grep -i $item >> /dev/null echo $issue | grep -i $item >> /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
system=$item system=$item
fi fi
done done
case $system in case $system in
ubuntu|debian|raspbian) ubuntu|debian|raspbian)
echo "Updating Ubuntu/Debian.." echo "Updating Ubuntu/Debian.."
sudo apt-get update && sudo apt-get dist-upgrade sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y
;; ;;
arch|antergos) arch|antergos)
echo "Updating Arch Linux.." echo "Updating Arch Linux.."
@ -151,45 +159,16 @@ update()
return 1 return 1
;; ;;
esac esac
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "error: something went wrong." echo "error: something went wrong."
return 1 return 1
fi fi
} }
# **** old content which i keep here for reference ****
## Cross-platform install routine
#install()
#{
# systems="ubuntu arch"
# issue="$(cat /etc/issue)"
# packages=$*
# for item in $systems; do
# echo $issue | grep -i $item >> /dev/null
# if [ $? -eq 0 ]; then
# system=$item
# fi
# done
#
# case $system in
# ubuntu)
# sudo apt-get install -y $packages
# ;;
# arch)
# sudo pacman -Sy --noconfirm $packages
# ;;
# ?)
# echo "unknown system. could not run install."
# ;;
# esac
#}
## Thinkpad Trackpoint input fix (for for thinkpad x131e/chromebook) ## Thinkpad Trackpoint input fix (for for thinkpad x131e/chromebook)
#fixtrackpoint() #fixtrackpoint() {
#{
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation" 1 # xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation" 1
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Button" 2 # xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Button" 2
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 200 # xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 200