Adjust repo URL.
[inetstation.git] / bootstrap.sh
1 #!/bin/bash -x
2
3 GITPROJ=https://chaos.expert/ccc-ffm/4Refugees-InternetCafe
4 ATHQ=false
5 HQSERVER="install.hq"
6 PROXYURL="http://${HQSERVER}:8080/"
7 if [ "$1" != "RUNME" ]; then
8
9     #pull myself from git repo
10     wget --prefer-family=IPv4 "${GITPROJ}/raw/master/bootstrap.sh" -O /root/bootstrap.sh
11     chmod u+x /root/bootstrap.sh
12     exec /root/bootstrap.sh RUNME
13     exit
14 fi
15
16 #check for install.hq
17 if ping -c 5 ${HQSERVER}; then
18     ATHQ=true
19 fi
20
21
22 if [ "$ATHQ" = true ]; then
23     echo 'Acquire::http::Proxy "${PROXYURL}";' > /etc/apt/apt.conf
24 else
25     echo "#no proxy" > /etc/apt/apt.conf
26 fi
27
28 apt update
29 apt install --assume-yes git puppet vim curl
30 apt full-upgrade --assume-yes
31
32
33 if [ ! -e /etc/puppet/.git ]; then  
34     mv /etc/puppet /etc/puppet.orig
35     git clone ${GITPROJ}.git /etc/puppet
36 fi
37
38
39 cd /etc/puppet
40 git remote set-url origin ${GITPROJ}.git
41 git pull
42 git submodule init
43 git submodule update
44 git pull
45 puppet apply /etc/puppet/manifests/site.pp
46
47 if [ "$ATHQ" = true ]; then
48     facter --yaml --puppet > /tmp/facts.yaml
49     curl -T /tmp/facts.yaml ftp://${HQSERVER}/refugee-notebooks/${HOSTNAME}.yaml
50 fi