X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=bookworm%2Fsetup_scripts%2Fsetup_home.sh;h=6467ef9a166a5419cc110c2ea6d4084f919eb3dd;hb=b2689a62b11cf9a4423ac51af582a12a17a781a0;hp=9dfbf5856bb513fb66eda8f4f1e6432de466cdae;hpb=c23514e257843acb215e435b2da06a24c11f39dd;p=config diff --git a/bookworm/setup_scripts/setup_home.sh b/bookworm/setup_scripts/setup_home.sh index 9dfbf58..6467ef9 100755 --- a/bookworm/setup_scripts/setup_home.sh +++ b/bookworm/setup_scripts/setup_home.sh @@ -1,100 +1,108 @@ #!/bin/sh set -e -debian_version="bookworm" . ./misc.sh expect_n_args 1 "(system name)" "$@" get_system_name_arg "$1" -git clone https://plomlompom.com/repos/clone/config cd $setup_scripts_dir ./copy_dirtree.sh "${config_tree_prefix}/home_files" "${HOME}" minimal user "${system_name}" -# public_repos_dir="${HOME}/public_repos" -# config_tree_prefix="${public_repos_dir}/config/${debian_version}" -# # path_borgscript="${config_tree_prefix}//borg.sh" -# setup_scripts_dir="${config_tree_prefix}/setup_scripts" -# repos_list_file="${public_repos_dir}/repos" -# # dir_secrets="${HOME}/tmp_secrets" -# # borgkeys_dir=~/.config/borg/keys -# # borgrepos_file=~/.borgrepos -# ssh_dir=~/.ssh -# # authinfo_file=.authinfo -# maildir=~/mail/maildir -# -# ensure_repo() { -# repo_name="${1}" -# if [ ! -d "${public_repos_dir}/${repo_name}" ]; then -# cd "${public_repos_dir}" -# git clone plom@plomlompom.com:/var/repos/${repo_name} -# fi -# } -# -# # Set up iniitial non-public parts of infrastructure: SSH authentication. -# cd "${dir_secrets}" -# mkdir -p "${ssh_dir}" -# echo "Setting up .ssh" -# cp id_rsa ~/.ssh -# stty -echo -# ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub -# stty echo -# eval $(ssh-agent) -# ssh-add -# ssh-keyscan -H "plomlompom.com" >> ~/.ssh/known_hosts -# -# # Clone config to copy dotfiles etc. from it. -# cd -# mkdir -p "${public_repos_dir}" -# ensure_repo config -# cd "${setup_scripts_dir}" -# ./copy_dirtree.sh "${config_tree_prefix}/home_files" "${HOME}" minimal user "${system_name}" -# +secrets_dev="sdb" +source_dir_secrets="/media/${secrets_dev}/to_usb" +target_dir_secrets="${HOME}/tmp_secrets" +echo "Put secrets drive into slot for /dev/${secrets_dev}." +while [ ! -e /dev/"${secrets_dev}" ]; do + sleep 1 +done +stty -echo +printf "Secrets passphrase: " +read SECRETS_PASS +stty echo +echo "" # newline so user knows their input return was accepted +sudo -v +echo "${SECRETS_PASS}" | sudo pmount /dev/"${secrets_dev}" +cp -a "${source_dir_secrets}" "${target_dir_secrets}" +sudo chown -R plom:plom "${target_dir_secrets}" +sudo pumount "${secrets_dev}" +echo "You can remove /dev/${secrets_dev} now." + +# Set up iniitial non-public parts of infrastructure: SSH authentication. +ssh_dir=~/.ssh +cd "${target_dir_secrets}" +mkdir -p "${ssh_dir}" +echo "Setting up .ssh" +cp id_rsa ~/.ssh +stty -echo +ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub +stty echo +eval $(ssh-agent) +ssh-add +ssh-keyscan -H "plomlompom.com" >> ~/.ssh/known_hosts + +# Fill ~/public_repos. +public_repos_dir="${HOME}/public_repos" +repos_list_file="${public_repos_dir}/repos" +mkdir -p "${public_repos_dir}" +cat "${repos_list_file}" | while read line; do + first_char=$(echo "${line}" | cut -c1) + if [ "${first_char}" = "#" ]; then + continue + fi + repo_name="${line}" + if [ ! -d "${public_repos_dir}/${repo_name}" ]; then + cd "${public_repos_dir}" + git clone plom@plomlompom.com:/var/repos/${repo_name} + fi +done + +# Remove redundant config repo copy. +config_tree_prefix="${public_repos_dir}/config/${debian_version}" +rm -rf ~/config + # # Set up native messenger for tridactyl. # version='ef9f02d0da258f68d7faf8898707f6d83d90d07a' # curl -fsSl "https://raw.githubusercontent.com/tridactyl/tridactyl/${version}/native/install.sh" | bash -# -# # Set up further non-public parts of infrastructure. -# cd "${dir_secrets}" -# script -c 'gpg --import secret_keys.asc' /dev/null -# tar xf borg_keyfiles.tar -# mkdir -p "${borgkeys_dir}" -# mv borg_keyfiles/* "${borgkeys_dir}" -# # .authinfo may not be present on every secrets drive yet -# if [ -f "${authinfo_file}" ]; then -# cp "${authinfo_file}" ~ -# fi -# cd -# rm -rf "${dir_secrets}" -# -# # Sync org dir via borgbackup. For this we need the borgbackup servers -# # in our .ssh/known_hosts file. -# cat "${borgrepos_file}" | while read line; do -# first_char=$(echo "${line}" | cut -c1) -# if [ "${first_char}" = "#" ]; then -# continue -# fi -# server=$(echo "${line}" | sed 's/.*@//') -# ssh-keyscan "${server}" >> "${ssh_dir}"/known_hosts -# done -# BORG_PASSPHRASE="${SECRETS_PASS}" "${path_borgscript}" orgpull -# -# # Fill ~/public_repos. -# cat "${repos_list_file}" | while read line; do -# first_char=$(echo "${line}" | cut -c1) -# if [ "${first_char}" = "#" ]; then -# continue -# fi -# ensure_repo "${line}" -# done -# + +# Set up further non-public parts of infrastructure. +cd "${target_dir_secrets}" +script -c 'gpg --import secret_keys.asc' /dev/null +path_borgscript="${config_tree_prefix}//borg.sh" + +# borg setup +borgkeys_dir=~/.config/borg/keys +borgrepos_file=~/.borgrepos +tar xf borg_keyfiles.tar +mkdir -p "${borgkeys_dir}" +mv borg_keyfiles/* "${borgkeys_dir}" +# Sync org dir via borgbackup. For this we need the borgbackup servers +# in our .ssh/known_hosts file. +cat "${borgrepos_file}" | while read line; do + first_char=$(echo "${line}" | cut -c1) + if [ "${first_char}" = "#" ]; then + continue + fi + server=$(echo "${line}" | sed 's/.*@//') + ssh-keyscan "${server}" >> "${ssh_dir}"/known_hosts +done +BORG_PASSPHRASE="${SECRETS_PASS}" "${path_borgscript}" orgpull + +# .authinfo may not be present on every secrets drive yet +authinfo_file=.authinfo +if [ -f "${authinfo_file}" ]; then + cp "${authinfo_file}" ~ +fi +cd + +maildir=~/mail/maildir # # Set up e-mail system. Note that we only do mbsync if the imap pass file # # is found. It may not be present on every secrets drive yet, so we have to # # deal with the possibility of it being absent at this point. -# mkdir -p "${maildir}" # expected by mbsync/isync -# if [ -f "${HOME}/${authinfo_file}" ]; then -# mbsync -a -# notmuch new -# fi -# -# # # Final note on how to integrate tridactyl. -# # echo "TODO: As tridactyl user, don't forget to do :source on the first Firefox run, wait a little while (Tridactyl needs to walk through all commands in the .tridactylrc) and then re-start." +mkdir -p "${maildir}" # expected by mbsync/isync +if [ -f "${HOME}/${authinfo_file}" ]; then + mbsync -a + notmuch new +fi + +# # Final note on how to integrate tridactyl. +# echo "TODO: As tridactyl user, don't forget to do :source on the first Firefox run, wait a little while (Tridactyl needs to walk through all commands in the .tridactylrc) and then re-start."