-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-script-tester
executable file
·66 lines (60 loc) · 1.85 KB
/
prepare-script-tester
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
61
62
63
64
65
66
#!/usr/bin/env bash
#
# Template VM Image Builder
# Copyright (C) 2017-2025 by Thomas Dreibholz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact: [email protected]
set -eu
if [ $# -lt 1 ] ; then
echo >&2 "Usage: $0 vm_address"
exit 1
fi
user="${1//@*/}"
address="${1//*@/}"
if [ "${user}" == "${address}" ] ; then
user="nornetpp"
fi
ssh-copy-id -oStrictHostKeyChecking=no "${user}@${address}"
ssh -t "${user}@${address}" '
echo "nornetpp ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/99-nornetpp
if ! which git || ! which joe ; then
if [ -x /usr/bin/apt ] ; then
sudo /usr/bin/apt install -y git joe
elif [ -x /usr/bin/dnf ] ; then
sudo /usr/bin/dnf install -y git joe
elif [ -x /usr/bin/pkg ] ; then
sudo /usr/bin/pkg install -y git joe
fi
fi
if [ ! -d ~/src/vmimage-builder-scripts ] ; then
git clone https://[email protected]/simula/nornet-vmimage-builder-scripts ~/src/vmimage-builder-scripts
cd ~/src/vmimage-builder-scripts
git config pull.rebase true
# git checkout dreibh/freebsd
fi
if [ ! -e ~/.gitconfig ] ; then
cat >~/.gitconfig <<EOF
[user]
name = Thomas Dreibholz
email = [email protected]
[push]
default = simple
[color]
ui = auto
EOF
fi
'
ssh "${user}@${address}"