forked from Clommunity/cloudynitzar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudynitzar.sh
87 lines (71 loc) · 2.37 KB
/
cloudynitzar.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# Agafa variables necessaries
DISTRIBUTION=$(lsb_release -c|cut -f 2)
AREAS="main contrib"
ARCHDIR=/etc/apt/sources.list.d/
LPACKAGES="https://raw.githubusercontent.com/Clommunity/lbmake/master/packages"
CPACKAGES="avahi-ps.chroot cDistro.chroot getinconf-client.chroot serf.chroot"
HOOKPATH="https://raw.githubusercontent.com/Clommunity/lbmake/master/hooks/"
ARCH=$(uname -m|sed 's/i.86/i386/'|sed 's/^arm.*/arm/')
DIST="https://raw.githubusercontent.com/Clommunity/cloudynitzar/master/dist"
CURL="/usr/bin/curl"
SPECIFICS_EXT=".list"
[ -z "$DISTRIBUTION" ] && { apt-get install -y lsb-release; DISTRIBUTION=$(lsb_release -c|cut -f 2); }
# funcions globals
getkey() {
gpg --keyserver pgpkeys.mit.edu --recv-key $1 && gpg --export --armor $1 | apt-key add -
}
jessie() {
chsh -s /bin/sh www-data
chsh -s /bin/sh nobody
}
getHTTPCode() {
$CURL -s -o /dev/null -I -w "%{http_code}" $1
}
specifics() {
[ $(getHTTPCode "${DIST}/${1}/${2}${SPECIFICS_EXT}") == "200" ] && {
while IFS='|' read name destin mod;
do
echo "COPY ${DIST}/${1}/${2}/$name -> ${destin}/${name} $mod"
mkdir -p ${destin}
$CURL -s "${DIST}/${1}/${2}/${name}" -o "${destin}/${name}"
chmod $mod ${destin}/${name}
done < <($CURL -s "${DIST}/${1}/${2}${SPECIFICS_EXT}")
}
}
# Instal·lar Repositoris
mkdir -p ${ARCHDIR}
# Add Backports Repo
echo "deb http://ftp.debian.org/debian ${DISTRIBUTION}-backports ${AREAS}" > ${ARCHDIR}/backports.list
# Add Clommuntiy Repo
echo "deb http://repo.clommunity-project.eu/debian unstable/" > ${ARCHDIR}/cloudy.list
getkey A59C5DC8
# Add Guifi Repo
echo "deb http://serveis.guifi.net/debian guifi/" > ${ARCHDIR}/serveis.list
getkey 2E484DAB
# Paquets necessaris per l'instal·lació
apt-get update
apt-get upgrade -y --no-install-recommends
apt-get install -y curl unzip
# Instal·lar paquets debian
while IFS=': ' read name pkgs;
do
echo "Install $name."
apt-get install -y $pkgs
done < <($CURL -s $LPACKAGES)
# Instal·lar altres paquets
for i in $CPACKAGES
do
$CURL -s ${HOOKPATH}$i |ARCH=$ARCH sh -
done
# jessie changes
# activar la shell de www-data, per que es puguin executar coses amb su "www-data"...
[ "$(type -t $DISTRIBUTION)" == "function" ] && $DISTRIBUTION
specifics $ARCH $DISTRIBUTION
# Activar daemons
echo "Stop & Start cDistro."
/etc/init.d/cdistro stop
/etc/init.d/cdistro start
echo "Stop & Start SERF."
/etc/init.d/serf stop
/etc/init.d/serf start