renamed os update function to update-os and added update-keys function
This commit is contained in:
parent
2c5b22060f
commit
192ee7269c
|
@ -89,64 +89,8 @@ log() {
|
||||||
sleep 0.5; echo -e "[$level] ${@:2}"
|
sleep 0.5; echo -e "[$level] ${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# setup user accounts on linux systems
|
|
||||||
# update them if existing
|
|
||||||
# ? delete them
|
|
||||||
# add authorized_keys
|
|
||||||
setup_user() {
|
|
||||||
if [ $1 ]; then
|
|
||||||
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
|
|
||||||
log error "no username given"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
## RDP client
|
|
||||||
rdp() {
|
|
||||||
if [ -z $1 ]; then
|
|
||||||
echo -e "server: \c"
|
|
||||||
read server
|
|
||||||
else
|
|
||||||
server=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "username [davidadm]: \c"
|
|
||||||
read username
|
|
||||||
if [ -z $username ]; then
|
|
||||||
username="davidadm"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "domain [aec.at]: \c"
|
|
||||||
read domain
|
|
||||||
if [ -z $domain ]; then
|
|
||||||
domain="aec.at"
|
|
||||||
fi
|
|
||||||
|
|
||||||
which rdesktop >/dev/null
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
#rdesktop -u $username -p - -d $domain -g 1366x768 $server -k de
|
|
||||||
rdesktop -K -u $username -p - -d $domain -g workarea $server -k de
|
|
||||||
else
|
|
||||||
which xfreerdp >/dev/null
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
#xfreerdp +clipboard /v:$server /u:$username /d:$domain /size:1920x1080
|
|
||||||
xfreerdp /v:$server /u:$username /d:$domain /size:1366x768 -wallpaper:on
|
|
||||||
else
|
|
||||||
echo "error: no rdp client found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## OS upgrade for various systems
|
## OS upgrade for various systems
|
||||||
update() {
|
update-os() {
|
||||||
systems="ubuntu arch solus raspbian antergos elementary"
|
systems="ubuntu arch solus raspbian antergos elementary"
|
||||||
issue="$(cat /etc/issue)"
|
issue="$(cat /etc/issue)"
|
||||||
for item in $systems; do
|
for item in $systems; do
|
||||||
|
@ -158,19 +102,19 @@ update() {
|
||||||
|
|
||||||
case $system in
|
case $system in
|
||||||
ubuntu|debian|raspbian|elementary)
|
ubuntu|debian|raspbian|elementary)
|
||||||
echo "Updating Debian based system.."
|
log info "Updating Debian based system.."
|
||||||
sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y
|
sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y
|
||||||
;;
|
;;
|
||||||
arch|antergos)
|
arch|antergos)
|
||||||
echo "Updating Arch Linux.."
|
log info "Updating Arch Linux.."
|
||||||
sudo pacman -Syu
|
sudo pacman -Syu
|
||||||
;;
|
;;
|
||||||
solus)
|
solus)
|
||||||
echo "Updating Solus OS.."
|
log info "Updating Solus OS.."
|
||||||
sudo eopkg update-repo && sudo eopkg upgrade
|
sudo eopkg update-repo && sudo eopkg upgrade
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
echo "error: unknown system."
|
log error "error: unknown system."
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -181,14 +125,23 @@ update() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## update authorized_keys
|
||||||
## Thinkpad Trackpoint input fix (for for thinkpad x131e/chromebook)
|
update-keys() {
|
||||||
#fixtrackpoint() {
|
local SSH_PATH="$HOME/.ssh"
|
||||||
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation" 1
|
local SSH_KEYS="$SSH_PATH/authorized_keys"
|
||||||
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Button" 2
|
local KEYS_URL="https://public.socialnerds.org/ssh/$USER.pub"
|
||||||
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 200
|
if [ ! -d $SSH_PATH ]; then
|
||||||
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5
|
mkdir -p $SSH_PATH
|
||||||
# xinput set-prop "TPPS/2 IBM TrackPoint" "Device Accel Constant Deceleration" 0.75
|
log warn "Created new config folder [$SSH_PATH]"
|
||||||
#}
|
fi
|
||||||
|
chmod 700 $SSH_PATH
|
||||||
|
log info "Downloading updated authorized_keys file. [$SSH_KEYS]"
|
||||||
|
curl -s -u "$USER" -o "$SSH_KEYS" "$KEYS_URL"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
chmod 600 $SSH_KEYS
|
||||||
|
log success "Successfully updated authorized_keys file. [$SSH_KEYS]"
|
||||||
|
else
|
||||||
|
log error "Something went wrong while updating authorized_keys file. [$SSH_KEYS]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue