-
Notifications
You must be signed in to change notification settings - Fork 0
/
alis-cloud-init-ssh.sh
executable file
·54 lines (47 loc) · 1.22 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
#!/usr/bin/env bash
set -eu
GITHUB_USER="picodotdev"
BRANCH="master"
BRANCH_QUALIFIER=""
IP_ADDRESS=""
VM_TYPE="virtualbox"
VM_NAME="Arch Linux"
CONFIG_FILE_SH=""
while getopts "b:c:i:t:n:" 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}
;;
esac
done
if [ "$BRANCH" == "sid" ]; then
BRANCH_QUALIFIER="-sid"
fi
if [ "$IP_ADDRESS" == "" -a "$VM_TYPE" != "" -a "$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\""
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