1 | #!/bin/sh |
---|
2 | |
---|
3 | # Slackware Package Build Script for fail2ban |
---|
4 | # Home Page http://www.fail2ban.org/wiki/index.php/Main_Page |
---|
5 | |
---|
6 | # Copyright (c) 2008-2010, Nishant Limbachia, Hoffman Estates, IL, USA |
---|
7 | # <nishant _AT_ mnspace _DOT_ net> |
---|
8 | # All rights reserved. |
---|
9 | |
---|
10 | # Redistribution and use of this script, with or without modification, is |
---|
11 | # permitted provided that the following conditions are met: |
---|
12 | |
---|
13 | # 1. Redistributions of script must retain the above copyright notice, |
---|
14 | # this list of conditions and the following disclaimer. |
---|
15 | |
---|
16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
17 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
18 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
19 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
23 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
24 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
25 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
27 | |
---|
28 | PRGNAM=fail2ban |
---|
29 | VERSION=${VERSION:-0.8.4} |
---|
30 | BUILD=${BUILD:-1} |
---|
31 | TAG=${TAG:-_SBo} |
---|
32 | |
---|
33 | # Automatically determine the architecture we're building on: |
---|
34 | if [ -z "$ARCH" ]; then |
---|
35 | case "$( uname -m )" in |
---|
36 | i?86) ARCH=i486 ;; |
---|
37 | arm*) ARCH=arm ;; |
---|
38 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
39 | *) ARCH=$( uname -m ) ;; |
---|
40 | esac |
---|
41 | fi |
---|
42 | |
---|
43 | CWD=$(pwd) |
---|
44 | TMP=${TMP:-/tmp/SBo} |
---|
45 | PKG=$TMP/package-$PRGNAM |
---|
46 | OUTPUT=${OUTPUT:-/tmp} |
---|
47 | |
---|
48 | set -e |
---|
49 | |
---|
50 | # clean up from previous builds |
---|
51 | rm -fr $PKG $TMP/$PRGNAM-$VERSION |
---|
52 | mkdir -p $PKG $TMP $OUTPUT |
---|
53 | cd $TMP |
---|
54 | tar xjf $CWD/$PRGNAM-$VERSION.tar.bz2 |
---|
55 | cd $TMP/$PRGNAM-$VERSION |
---|
56 | chown -R root.root . |
---|
57 | find . \ |
---|
58 | \( -perm 777 -o -perm 775 -o -perm 771 -o -perm 711 -o -perm 555 -o -perm 551 -o -perm 511 \) \ |
---|
59 | -exec chmod 755 {} \; -o \ |
---|
60 | \( -perm 666 -o -perm 664 -o -perm 660 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
61 | -exec chmod 644 {} \; |
---|
62 | |
---|
63 | python setup.py install --root=$PKG |
---|
64 | |
---|
65 | # installing man pages |
---|
66 | mkdir -p $PKG/usr/man/man1 |
---|
67 | install -m 0644 man/fail2ban-client.1 man/fail2ban-regex.1 \ |
---|
68 | man/fail2ban-server.1 $PKG/usr/man/man1 |
---|
69 | |
---|
70 | # move config files to .new |
---|
71 | ( cd $PKG/etc/fail2ban |
---|
72 | for file in $(find . -type f); do |
---|
73 | mv $file "$file.new" |
---|
74 | done |
---|
75 | ) |
---|
76 | # compress man pages |
---|
77 | ( cd $PKG/usr/man |
---|
78 | find . -type f -exec gzip -9 {} \; |
---|
79 | for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done |
---|
80 | ) |
---|
81 | |
---|
82 | # install startup script |
---|
83 | install -D -m 0644 $CWD/rc.fail2ban $PKG/etc/rc.d/rc.fail2ban.new |
---|
84 | |
---|
85 | # install logrotate script |
---|
86 | install -D -m 0644 $CWD/fail2ban.logrotate $PKG/etc/logrotate.d/fail2ban.new |
---|
87 | |
---|
88 | # make directory for socket and pid file |
---|
89 | mkdir -p $PKG/var/run/fail2ban |
---|
90 | |
---|
91 | mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION |
---|
92 | cp -a COPYING ChangeLog PKG-INFO README TODO $PKG/usr/doc/$PRGNAM-$VERSION |
---|
93 | cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild |
---|
94 | |
---|
95 | #xbit startup script |
---|
96 | chmod +x $PKG/etc/rc.d/rc.fail2ban.new |
---|
97 | |
---|
98 | # building package |
---|
99 | mkdir -p $PKG/install |
---|
100 | cat $CWD/doinst.sh > $PKG/install/doinst.sh |
---|
101 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
102 | |
---|
103 | cd $PKG |
---|
104 | /sbin/makepkg -l n -c n $CWD/$PRGNAM.pkg |
---|
105 | echo $VERSION > $CWD/$PRGNAM.version && |
---|
106 | arch > $CWD/$PRGNAM.arch |
---|
107 | cd $OUTPUT |
---|