2019-10-29 15:59:00 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Exit on errors
|
|
|
|
set -e
|
|
|
|
|
2020-08-21 20:46:11 +02:00
|
|
|
for arg; do
|
|
|
|
case "$arg" in
|
|
|
|
--no-creds)
|
|
|
|
NOCREDS=1
|
|
|
|
;;
|
|
|
|
--no-lang)
|
|
|
|
NOLANG=1
|
|
|
|
;;
|
|
|
|
--no-yay)
|
|
|
|
NOYAY=1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown option '$arg'" >&2
|
|
|
|
echo "Usage: $0 [--no-creds] [--no-lang] [--no-yay]" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2019-10-29 15:59:00 +01:00
|
|
|
# Install pre-requisite packages for installing packages and connecting
|
|
|
|
prerequisite() {
|
2020-08-22 20:27:46 +02:00
|
|
|
sudo pacman -Syu --noconfirm --needed base base-devel git stow mosh jq
|
2019-10-29 15:59:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install the yay AUR helper
|
|
|
|
install-yay() {
|
|
|
|
git clone https://aur.archlinux.org/yay.git
|
|
|
|
pushd yay || exit 1
|
|
|
|
makepkg -si
|
|
|
|
popd || exit 1
|
|
|
|
}
|
|
|
|
|
2020-04-21 19:36:11 +02:00
|
|
|
# Keyboard and language setup
|
|
|
|
setup-lang() {
|
|
|
|
# A good QWERTY keyboard with easy access to accents
|
|
|
|
sudo localectl set-x11-keymap fr pc105 us
|
|
|
|
# FIXME: no international keyboard in VC for now
|
|
|
|
sudo localectl set-keymap --no-convert us
|
|
|
|
}
|
|
|
|
|
2020-05-01 16:35:39 +02:00
|
|
|
get-doc() {
|
|
|
|
# $1: name of folder which contains the wanted document
|
|
|
|
# $2: name of the document
|
|
|
|
# $3: destination
|
|
|
|
# $4: permissions
|
|
|
|
|
|
|
|
local FOLDER_ID
|
|
|
|
local NOTES
|
|
|
|
FOLDER_ID="$(bw list folders |
|
|
|
|
jq '.[] | select(.name == "'"$1"'") | .id' |
|
|
|
|
cut -d'"' -f2)"
|
|
|
|
|
|
|
|
NOTES="$(bw list items --folderid "$FOLDER_ID" |
|
|
|
|
jq '.[] | select(.name == "'"$2"'") | .notes' |
|
|
|
|
cut -d'"' -f2)"
|
|
|
|
|
|
|
|
printf "%b" "$NOTES" > "$3"
|
|
|
|
chmod "$4" "$3"
|
|
|
|
}
|
|
|
|
|
|
|
|
get-ssh() {
|
|
|
|
mkdir -p "$HOME/.ssh"
|
|
|
|
chmod 700 "$HOME/.ssh"
|
|
|
|
|
|
|
|
get-doc "SysAdmin/SSH" "shared-key-public" "$HOME/.ssh/shared_rsa.pub" 644
|
|
|
|
get-doc "SysAdmin/SSH" "shared-key-private" "$HOME/.ssh/shared_rsa" 600
|
|
|
|
}
|
|
|
|
|
|
|
|
get-creds() {
|
2020-08-21 20:46:11 +02:00
|
|
|
if [ -z "${BW_SESSION-set}" ]; then
|
2020-05-01 16:35:39 +02:00
|
|
|
BW_SESSION="$(bw login --raw)"
|
|
|
|
export BW_SESSION
|
|
|
|
fi
|
|
|
|
|
|
|
|
get-ssh
|
|
|
|
}
|
|
|
|
|
2019-10-29 15:59:00 +01:00
|
|
|
prerequisite
|
2020-08-21 20:46:11 +02:00
|
|
|
[ -z "$NOYAY" ] && install-yay
|
|
|
|
[ -z "$NOLANG" ] && setup-lang
|
|
|
|
[ -z "$NOCREDS" ] && get-creds
|
2020-08-22 20:42:20 +02:00
|
|
|
exit 0
|