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}"
|
||||
}
|
||||
|
||||
# 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
|
||||
update() {
|
||||
update-os() {
|
||||
systems="ubuntu arch solus raspbian antergos elementary"
|
||||
issue="$(cat /etc/issue)"
|
||||
for item in $systems; do
|
||||
|
@ -158,19 +102,19 @@ update() {
|
|||
|
||||
case $system in
|
||||
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
|
||||
;;
|
||||
arch|antergos)
|
||||
echo "Updating Arch Linux.."
|
||||
log info "Updating Arch Linux.."
|
||||
sudo pacman -Syu
|
||||
;;
|
||||
solus)
|
||||
echo "Updating Solus OS.."
|
||||
log info "Updating Solus OS.."
|
||||
sudo eopkg update-repo && sudo eopkg upgrade
|
||||
;;
|
||||
?)
|
||||
echo "error: unknown system."
|
||||
log error "error: unknown system."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
@ -181,14 +125,23 @@ update() {
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
## Thinkpad Trackpoint input fix (for for thinkpad x131e/chromebook)
|
||||
#fixtrackpoint() {
|
||||
# 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 Timeout" 200
|
||||
# xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5
|
||||
# xinput set-prop "TPPS/2 IBM TrackPoint" "Device Accel Constant Deceleration" 0.75
|
||||
#}
|
||||
|
||||
## update authorized_keys
|
||||
update-keys() {
|
||||
local SSH_PATH="$HOME/.ssh"
|
||||
local SSH_KEYS="$SSH_PATH/authorized_keys"
|
||||
local KEYS_URL="https://public.socialnerds.org/ssh/$USER.pub"
|
||||
if [ ! -d $SSH_PATH ]; then
|
||||
mkdir -p $SSH_PATH
|
||||
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