summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-11-22 16:28:43 -0600
committerCraig Jennings <c@cjennings.net>2024-11-22 16:28:43 -0600
commit61243d1d701673ed48f541ecc588d072c480eee9 (patch)
tree0db1578267840c0428ea794855ffade0916b14cf
parent456f01a43c0d44ede7c5d28783566664486210b4 (diff)
decryption and menu
- added key retrieval and setting up ssh daemon - added the following menu: base system: arch install compatible with my setup (archsetup) workstation: base system to full workstation (archinstall) distrobox: my default install inside distrobox container (archdistrobox) ssh: retrieve keys and setup ssh for remote work (setup_sshd function)
-rwxr-xr-xinit60
1 files changed, 45 insertions, 15 deletions
diff --git a/init b/init
index 3d6b6b3..b9d0d4d 100755
--- a/init
+++ b/init
@@ -4,48 +4,78 @@
# Craig Jennings <c@cjennings.net>
# An archsetup script to welcome user, present options, and setup ssh
# server from the live cd. Functions to installing base arch and setup
-# the workstation occur in other scripts, called by this script.
+# the workstation occur in other scripts, called by this script.
# Run as root after booting the live cd and issuing the following command:
# curl -s https://cjennings.net/archsetup/init | sh
-
-
welcome () {
clear
+ echo ""
echo "ArchSetup"
echo "---------"
echo ""
echo ""
}
+check_root_or_exit () {
+ if [ "$EUID" -ne 0 ]
+ then echo "Please run as root"
+ exit
+ fi
+}
+
setup_ssh () {
- systemctl start sshd
+ # retrieve keys from repo and decrypt
+ echo "retrieving keys for decryption..."
+ {
+ mkdir -p "$HOME/.ssh/"
+ # retrieve keys from dotfiles repo and decrypt the keys
+ (git clone --depth 1 https://git.cjennings.net/dotfiles.git \
+ "$HOME/dotfiles/") >> /dev/null
+ cp "$HOME/dotfiles/system/.ssh/*" "$HOME/.ssh/"
+ rm -rf "$HOME/dotfiles/"
+ } > /dev/null
+ cd "$HOME/.ssh/"
+ gpg --decrypt "$HOME/ssh.tar.gz.gpg" | tar -zxf -
+
+ # set proper permissions on .ssh directory
+ cd "$HOME" && chmod 600 $HOME/.ssh/* && chmod 700 $HOME/.ssh \
+ && chmod 644 $HOME/.ssh/*.pub
+ # setup ssh
+ echo "setting up ssh daemon..."
+ systemctl start sshd
echo "root:welcome" | chpasswd
hostname=$(</etc/hostname)
ipaddress=$(ip addr show wlan0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
- echo ""; echo ""; echo "init complete. "
+ # notify user
+ echo ""; echo ""
echo "you may ssh root@$hostname or ssh root@$ipaddress using the password 'welcome'"
}
############ SCRIPT
+check_root_or_exit
+
+# present menu
echo "Choose:"
-echo " (1) install the arch linux base system"
-echo " (2) setup the base system as a workstation"
-echo " (3) allow ssh to this live iso"
+echo " (1) create an arch linux base install"
+echo " (2) turn a base install into a full workstation"
+echo " (3) generate a workstation in an arch distrobox container"
+echo " (4) allow ssh to this live iso"
echo " (Enter 1, 2, or 3) :"
read setup
-if [ "$setup" = "arch" ]; then
- # run the arch setup script
- echo
-
-elif [ "$setup" = "ssh" ]; then
- setup_ssh #function above
-elif [ "$setup" = "ssh" ]; then
+if [ "$setup" = "1" ]; then
+ echo "this will call the archinstall script"
+elif [ "$setup" = "2" ]; then
+ echo "this will call the archsetup script"
+elif [ "$setup" = "3" ]; then
+ echo "this will call the archsetup-distrobox script"
+elif [ "$setup" = "4" ]; then
+ setup_ssh
else
echo "Error: Unknown setup option. Please enter 'arch' or 'ssh'."
exit 1