-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstaller.sh
executable file
·63 lines (51 loc) · 1.4 KB
/
installer.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
#!/bin/bash
INSTALLDIR=$1
REPODIR=$2
SUBSCRIBE=$3
if [ -z "$INSTALLDIR" ]; then
echo "Usage: $(basename $0) <installation dir> [repo dir] [subscribe]"
exit 1
fi
if [ -z "$REPODIR" ]; then
REPODIR="$INSTALLDIR/repos"
fi
mkdir -p $INSTALLDIR/{bin,etc/{dtmrepo.conf.d,dtmrepo.repos.d},var/{log,cache/dtmrepo}} $REPODIR
if [ "$?" -ne 0 ]; then
echo "Error creating installation directory tree."
exit 1
fi
echo -e "#!/bin/bash\n\nINSTALLDIR=$INSTALLDIR" > $INSTALLDIR/bin/dtmrepo
tail -n +4 dtmrepo >> $INSTALLDIR/bin/dtmrepo
chmod +x $INSTALLDIR/bin/*
cat <<EOF > $INSTALLDIR/etc/dtmrepo.conf
[global]
rootdir = $REPODIR
confdir = $INSTALLDIR/etc/dtmrepo.conf.d
yumconf = $INSTALLDIR/etc/dtmrepo-yum.conf
keep = 3
arch = x86_64
subscribed = 0
EOF
cat <<EOF > $INSTALLDIR/etc/dtmrepo-yum.conf
[main]
cachedir = $INSTALLDIR/var/cache/dtmrepo
logfile = $INSTALLDIR/var/log/dtmrepo.log
obsoletes = 1
plugins = 1
enabled = false
reposdir = $INSTALLDIR/etc/dtmrepo.repos.d
EOF
rpm -q --quiet httpd || yum -y install httpd
if [ "$?" -ne 0 ]; then
echo "Error installing httpd."
exit 1
fi
yum -y install createrepo yum-utils
\cp httpd-dtmrepo.conf /etc/httpd/conf.d/dtmrepo.conf
ln -sf $REPODIR /var/www/dtmrepo
chkconfig httpd on
service httpd start
if [ "$SUBSCRIBE" == "subscribe" ]; then
sed -i 's/^subscribed.\+/subscribed = 1/' $INSTALLDIR/etc/dtmrepo.conf
$INSTALLDIR/bin/dtmrepo -i
fi