-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd-profile.sh
executable file
·65 lines (54 loc) · 1.75 KB
/
add-profile.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
61
62
63
64
65
#!/bin/sh
. /opt/farm/scripts/functions.dialog
if [ "$1" = "" ]; then
echo "usage: $0 <profile>"
exit 1
fi
template=~/.serverfarmer/provisioning/$1/variables.sh
fwconfig="/opt/farm/ext/firewall/.git/config"
domain=`/opt/farm/config/get-external-domain.sh`
if [ -f $template ]; then
echo "provisioning configuration template \"$1\" already found, exiting"
exit 0
fi
if [ -f $fwconfig ] && grep -q git@ $fwconfig; then
giturl=`grep git@ $fwconfig |awk "{ print \\$3 }"`
else
giturl="[email protected]:your/firewall.git"
fi
SNMP_COMMUNITY="`input \"enter snmp v2 community for provisioning\" put-your-snmp-community-here`"
SMTP_RELAY="`input \"enter default smtp relay hostname for provisioning\" smtp.gmail.com`"
SMTP_USERNAME="`input \"[$SMTP_RELAY] enter login\" [email protected]`"
SMTP_PASSWORD="`input \"[$SMTP_RELAY] enter password for $SMTP_USERNAME\" my-password`"
FW_REPOSITORY="`input \"enter firewall repository url\" $giturl`"
FW_SSH_KEY="`input \"[$FW_REPOSITORY] enter ssh key name\" id_github_firewall`"
mkdir -p ~/.serverfarmer/provisioning/$1
echo "#!/bin/sh
#
# Settings to use in unattended setup mode; please fill in all variables.
#
# extensions part:
#
export SNMP_COMMUNITY=$SNMP_COMMUNITY
#
# core SF part:
#
export SMTP_RELAY=$SMTP_RELAY
export SMTP_USERNAME=$SMTP_USERNAME
export SMTP_PASSWORD=$SMTP_PASSWORD
#
# firewall - optional private repository:
#
export FW_REPOSITORY=$FW_REPOSITORY
export FW_SSH_KEY=$FW_SSH_KEY
#
# Github username (or organization short name), where you have forked
# Server Farmer main repository.
#
export SF_GITHUB=`grep github.com /opt/farm/.git/config |rev |cut -d'/' -f2 |rev`
#
# Email address for confirmations about successful setups.
#
export SF_CONFIRM=serverfarmer-provisioning@$domain
" >$template
chmod 0600 $template