forked from picodotdev/alis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alis-cloud-init-ssh.sh
executable file
·60 lines (52 loc) · 1.44 KB
/
alis-cloud-init-ssh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -eu
# ./alis-cloud-init-ssh.sh -b sid -i 192.168.122.61 -c alis-config-efi-ext4-luks-systemd.sh
GITHUB_USER="picodotdev"
BRANCH="master"
BRANCH_QUALIFIER=""
IP_ADDRESS=""
VM_TYPE="virtualbox"
VM_NAME="Arch Linux"
CONFIG_FILE_SH="alis-config-efi-ext4-systemd.sh"
while getopts "b:c:i:n:t:u:" arg; do
case $arg in
b)
BRANCH="$OPTARG"
;;
c)
CONFIG_FILE_SH="$OPTARG"
;;
i)
IP_ADDRESS="$OPTARG"
;;
n)
VM_NAME="$OPTARG"
;;
t)
VM_TYPE="$OPTARG"
;;
u)
GITHUB_USER=${OPTARG}
;;
*)
echo "Unknown option: $arg"
exit 1
;;
esac
done
if [ "$BRANCH" == "sid" ]; then
BRANCH_QUALIFIER="-sid"
fi
if [ "$IP_ADDRESS" == "" ] && [ "$VM_TYPE" != "" ] && [ "$VM_NAME" != "" ]; then
IP_ADDRESS=$(VBoxManage guestproperty get "${VM_NAME}" "/VirtualBox/GuestInfo/Net/0/V4/IP" | cut -f2 -d " ")
fi
set -o xtrace
ssh-keygen -R "$IP_ADDRESS"
ssh-keyscan -H "$IP_ADDRESS" >> ~/.ssh/known_hosts
ssh -t -i cloud-init/alis.key root@"$IP_ADDRESS" "bash -c \"curl -sL https://raw.githubusercontent.com/${GITHUB_USER}/alis/${BRANCH}/download${BRANCH_QUALIFIER}.sh | bash -s -- -b ${BRANCH}\""
if [ -z "$CONFIG_FILE_SH" ]; then
ssh -t -i cloud-init/alis.key root@"$IP_ADDRESS"
else
ssh -t -i cloud-init/alis.key root@"$IP_ADDRESS" "bash -c \"configs/$CONFIG_FILE_SH\""
ssh -t -i cloud-init/alis.key root@"$IP_ADDRESS" "bash -c \"./alis.sh -w\""
fi