#!/bin/sh # Heavily based on the Slackware 13.0 SlackBuild # http://www.chillispot.info/ # # Slackware 13.0 # http://www.slacky.eu CWD=`pwd` TMP=${TMP:-/tmp/txz} NAME=chillispot PKG=$TMP/package/$NAME VERSION=1.1.0 ARCH=${ARCH:-i486} BUILD=4ks SOURCE=http://www.chillispot.info/download/$NAME-$VERSION.tar.gz if [ ! -e $NAME-$VERSION.tar.gz ]; then wget -c $SOURCE fi if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686"; SLKLDFLAGS=""; LIBDIRSUFFIX=""; CHOST=i486 elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686"; SLKLDFLAGS=""; LIBDIRSUFFIX=""; CHOST=i486 elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC"; SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64" fi if [ ! -d $TMP ]; then mkdir -p $TMP fi if [ ! -d $PKG ]; then mkdir -p $PKG fi echo "| Start SlackBuild $NAME-$VERSION |" cd $TMP tar xzvf $CWD/$NAME-$VERSION.tar.gz cd $NAME-$VERSION chown -R root:root . find . -perm 775 -exec chmod 755 {} \; find . -perm 664 -exec chmod 644 {} \; LDFLAGS="$SLKLDFLAGS" \ CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ ./configure --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --mandir=/usr/man \ --disable-static \ --program-prefix= \ --program-suffix= \ --build=$ARCH-slackware-linux make || exit 1 make install DESTDIR=$PKG || exit 1 mkdir -p $PKG/usr/doc/$NAME-$VERSION/SlackBuild cp -a AUTHORS NEWS COPYING ChangeLog README CREDITS INSTALL $PKG/usr/doc/$NAME-$VERSION cp -a doc/dictionary.chillispot doc/firewall.* doc/freeradius.users $PKG/usr/doc/$NAME-$VERSION mkdir -p $PKG/var/www/cgi-bin cp -a doc/hotspotlogin.cgi $PKG/var/www/cgi-bin `which chmod` 0755 $PKG/var/www/cgi-bin/hotspotlogin.cgi mkdir -p $PKG/etc/rc.d cp -a doc/chilli.conf $PKG/etc echo "#!/bin/sh" > $PKG/etc/rc.d/rc.chillispot echo "#" >> $PKG/etc/rc.d/rc.chillispot echo "# chilli This shell script takes care of starting and stopping" >> $PKG/etc/rc.d/rc.chillispot echo "# chilli." >> $PKG/etc/rc.d/rc.chillispot echo "#" >> $PKG/etc/rc.d/rc.chillispot echo "# description: ChilliSpot" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "# Wireless authenticator daemon." >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "[ -f /usr/sbin/chilli ] || exit 0" >> $PKG/etc/rc.d/rc.chillispot echo "[ -f /etc/chilli.conf ] || exit 0" >> $PKG/etc/rc.d/rc.chillispot echo "[ -f /var/www/cgi-bin/hotspotlogin.cgi ] || exit 0" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "RETVAL=0" >> $PKG/etc/rc.d/rc.chillispot echo "prog=\"chilli\"" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "start() {" >> $PKG/etc/rc.d/rc.chillispot echo " # Start daemons." >> $PKG/etc/rc.d/rc.chillispot echo " echo -n \$\"Starting \$prog: \"" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo " # Load tun module" >> $PKG/etc/rc.d/rc.chillispot echo " /sbin/modprobe tun >/dev/null 2>&1" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo " # Enable routing of packets: WARNING!!!" >> $PKG/etc/rc.d/rc.chillispot echo " # Users should enable this explicitly" >> $PKG/etc/rc.d/rc.chillispot echo " # echo 1 > /proc/sys/net/ipv4/ip_forward" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo " /usr/sbin/chilli" >> $PKG/etc/rc.d/rc.chillispot echo " RETVAL=\$?" >> $PKG/etc/rc.d/rc.chillispot echo " [ \$RETVAL -eq 0 ] && touch /var/lock/subsys/chilli" >> $PKG/etc/rc.d/rc.chillispot echo " if [ \$RETVAL -eq 0 ] ; then echo \"OK\" ; fi" >> $PKG/etc/rc.d/rc.chillispot echo " return \$RETVAL" >> $PKG/etc/rc.d/rc.chillispot echo "}" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "startdebug() {" >> $PKG/etc/rc.d/rc.chillispot echo " # Start daemons." >> $PKG/etc/rc.d/rc.chillispot echo " echo -n \$\"Starting \$prog: \"" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo " # Load tun module" >> $PKG/etc/rc.d/rc.chillispot echo " /sbin/modprobe tun >/dev/null 2>&1" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo " # Enable routing of packets: WARNING!!!" >> $PKG/etc/rc.d/rc.chillispot echo " # Users should enable this explicitly" >> $PKG/etc/rc.d/rc.chillispot echo " # echo 1 > /proc/sys/net/ipv4/ip_forward" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo " /usr/sbin/chilli --fg --debug" >> $PKG/etc/rc.d/rc.chillispot echo " RETVAL=\$?" >> $PKG/etc/rc.d/rc.chillispot echo " echo" >> $PKG/etc/rc.d/rc.chillispot echo " [ \$RETVAL -eq 0 ] && touch /var/lock/subsys/chilli" >> $PKG/etc/rc.d/rc.chillispot echo " return \$RETVAL" >> $PKG/etc/rc.d/rc.chillispot echo "}" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "stop() {" >> $PKG/etc/rc.d/rc.chillispot echo " # Stop daemons." >> $PKG/etc/rc.d/rc.chillispot echo " echo -n \$\"Shutting down \$prog: \"" >> $PKG/etc/rc.d/rc.chillispot echo " killall chilli" >> $PKG/etc/rc.d/rc.chillispot echo " RETVAL=\$?" >> $PKG/etc/rc.d/rc.chillispot echo " echo" >> $PKG/etc/rc.d/rc.chillispot echo " [ \$RETVAL = 0 ] && rm -f /var/lock/subsys/chilli /var/run/chilli.pid" >> $PKG/etc/rc.d/rc.chillispot echo " if [ \$RETVAL -eq 0 ] ; then echo \"OK\"; fi" >> $PKG/etc/rc.d/rc.chillispot echo " return \$RETVAL" >> $PKG/etc/rc.d/rc.chillispot echo "}" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "# See how we were called." >> $PKG/etc/rc.d/rc.chillispot echo "case "\$1" in" >> $PKG/etc/rc.d/rc.chillispot echo " start)" >> $PKG/etc/rc.d/rc.chillispot echo " start" >> $PKG/etc/rc.d/rc.chillispot echo " ;;" >> $PKG/etc/rc.d/rc.chillispot echo " startdebug)" >> $PKG/etc/rc.d/rc.chillispot echo " startdebug" >> $PKG/etc/rc.d/rc.chillispot echo " ;;" >> $PKG/etc/rc.d/rc.chillispot echo " stop)" >> $PKG/etc/rc.d/rc.chillispot echo " stop" >> $PKG/etc/rc.d/rc.chillispot echo " ;;" >> $PKG/etc/rc.d/rc.chillispot echo " restart|reload)" >> $PKG/etc/rc.d/rc.chillispot echo " stop" >> $PKG/etc/rc.d/rc.chillispot echo " start" >> $PKG/etc/rc.d/rc.chillispot echo " RETVAL=\$?" >> $PKG/etc/rc.d/rc.chillispot echo " ;;" >> $PKG/etc/rc.d/rc.chillispot echo " condrestart)" >> $PKG/etc/rc.d/rc.chillispot echo " if [ -f /var/lock/subsys/chilli ] ; then" >> $PKG/etc/rc.d/rc.chillispot echo " stop" >> $PKG/etc/rc.d/rc.chillispot echo " start" >> $PKG/etc/rc.d/rc.chillispot echo " RETVAL=\$?" >> $PKG/etc/rc.d/rc.chillispot echo " fi" >> $PKG/etc/rc.d/rc.chillispot echo " ;;" >> $PKG/etc/rc.d/rc.chillispot echo " status)" >> $PKG/etc/rc.d/rc.chillispot echo " if [ -f /var/run/chilli.pid ]" >> $PKG/etc/rc.d/rc.chillispot echo " then echo Chilli is running" >> $PKG/etc/rc.d/rc.chillispot echo " else echo Chilli is NOT running" >> $PKG/etc/rc.d/rc.chillispot echo " fi" >> $PKG/etc/rc.d/rc.chillispot echo " ;;" >> $PKG/etc/rc.d/rc.chillispot echo " *)" >> $PKG/etc/rc.d/rc.chillispot echo " echo \$\"Usage: \$0 {start|startdebug|stop|restart|condrestart|status}\"" >> $PKG/etc/rc.d/rc.chillispot echo " exit 1" >> $PKG/etc/rc.d/rc.chillispot echo "esac" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot echo "exit \$RETVAL" >> $PKG/etc/rc.d/rc.chillispot echo "" >> $PKG/etc/rc.d/rc.chillispot ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ) gzip -9 $PKG/usr/man/*/* mv $PKG/etc/chilli.conf $PKG/etc/chilli.conf.new mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/SlackBuild/slack-desc cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/SlackBuild/$NAME.SlackBuild cd $PKG requiredbuilder -v -y -s $CWD $PKG makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.txz if [ "$1" = "--cleanup" ]; then rm -rf $TMP/$NAME-$VERSION rm -rf $PKG fi