2012-04-14 16:22:27 +02:00
|
|
|
#!/bin/sh
|
2014-01-17 16:47:47 +01:00
|
|
|
## PirateBox installer script
|
2017-03-20 22:29:54 +01:00
|
|
|
## created by Matthias Strubel (c)2011-2017 GPL-3
|
2012-04-14 16:22:27 +02:00
|
|
|
##
|
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
PIRATEBOX_CONFIG="/opt/piratebox/conf/piratebox.con"
|
|
|
|
|
2016-05-10 20:09:49 +02:00
|
|
|
create_content_folder(){
|
|
|
|
|
|
|
|
echo "Creating 'content' folder on USB stick and move over stuff"
|
|
|
|
mkdir -p $WWW_CONTENT
|
|
|
|
cp -r $PIRATEBOX_FOLDER/www_content/* $WWW_CONTENT
|
|
|
|
|
|
|
|
[ ! -L $PIRATEBOX_FOLDER/www/content ] && \
|
|
|
|
ln -s $WWW_CONTENT $WWW_FOLDER/content
|
|
|
|
[ ! -e $WWW_FOLDER/favicon.ico ] && \
|
|
|
|
ln -s $WWW_CONTENT/favicon.ico $WWW_FOLDER
|
|
|
|
|
|
|
|
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $WWW_CONTENT -R
|
|
|
|
chmod u+rw $WWW_CONTENT
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-04-14 16:22:27 +02:00
|
|
|
# Load configfile
|
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ -z $1 ]; then
|
|
|
|
echo "Usage install_piratebox <part>"
|
2012-04-14 16:22:27 +02:00
|
|
|
echo " Parts: "
|
|
|
|
echo " part2 : sets Permissions and links correctly"
|
|
|
|
echo " imageboard : configures kareha imageboard with Basic configuration"
|
|
|
|
echo " should be installed in <Piratebox-Folder>/share/board"
|
|
|
|
echo " pyForum : Simple PythonForum"
|
2013-07-01 13:28:37 +02:00
|
|
|
echo " station_cnt : Adds Statio counter to your Box - crontab entry"
|
|
|
|
echo " flush_dns_reg : Installs crontask to flush dnsmasq regulary"
|
|
|
|
echo " hostname 'name' : Exchanges the Hostname displayed in browser"
|
2012-04-14 16:22:27 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ ! -f "$PIRATEBOX_CONFIG" ] ; then
|
|
|
|
echo "Config-File "$PIRATEBOX_CONFIG" not found..."
|
2012-04-14 16:22:27 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Load config
|
2017-03-20 22:29:54 +01:00
|
|
|
. "$PIRATEBOX_CONFIG"
|
2012-04-14 16:22:27 +02:00
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ $1 = 'pyForum' ] ; then
|
2012-04-14 16:22:27 +02:00
|
|
|
cp -v $PIRATEBOX_FOLDER/src/forest.py $WWW_FOLDER/cgi-bin
|
2016-10-30 14:07:52 +01:00
|
|
|
cp -v $PIRATEBOX_FOLDER/src/forest.css $WWW_FOLDER/content/css
|
2012-04-14 16:22:27 +02:00
|
|
|
mkdir -p $PIRATEBOX_FOLDER/forumspace
|
2016-10-30 14:07:52 +01:00
|
|
|
chmod a+rw -R $PIRATEBOX_FOLDER/forumspace 2> /dev/null
|
2012-04-26 21:40:15 +02:00
|
|
|
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $WWW_FOLDER/cgi-bin/forest.py
|
2016-11-17 06:54:48 +01:00
|
|
|
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $WWW_FOLDER/content/forest.css 2> /dev/null
|
2012-04-26 21:40:15 +02:00
|
|
|
echo "Copied the files. Recheck your PirateBox now. "
|
2012-04-14 16:22:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ $1 = 'part2' ] ; then
|
2013-01-22 12:35:56 +01:00
|
|
|
echo "Starting initialize PirateBox Part2.."
|
2012-04-14 16:22:27 +02:00
|
|
|
#Create directories
|
2012-05-13 09:55:03 +02:00
|
|
|
# mkdir -p $PIRATEBOX_FOLDER/share/Shared
|
|
|
|
mkdir -p $UPLOADFOLDER
|
2012-04-14 16:22:27 +02:00
|
|
|
mkdir -p $PIRATEBOX_FOLDER/share/board
|
|
|
|
mkdir -p $PIRATEBOX_FOLDER/share/tmp
|
|
|
|
mkdir -p $PIRATEBOX_FOLDER/tmp
|
|
|
|
|
2014-08-01 16:53:33 +02:00
|
|
|
#Distribute the Directory Listing files
|
|
|
|
$PIRATEBOX_FOLDER/bin/distribute_files.sh $SHARE_FOLDER/Shared true
|
|
|
|
#Set permissions
|
2012-04-14 16:22:27 +02:00
|
|
|
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $PIRATEBOX_FOLDER/share -R
|
|
|
|
chmod u+rw $PIRATEBOX_FOLDER/share
|
|
|
|
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $PIRATEBOX_FOLDER/www -R
|
|
|
|
chmod u+x $PIRATEBOX_FOLDER/www/cgi-bin/*
|
|
|
|
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $PIRATEBOX_FOLDER/tmp
|
|
|
|
chown $LIGHTTPD_USER:$LIGHTTPD_GROUP $PIRATEBOX_FOLDER/tmp -R
|
|
|
|
|
|
|
|
|
|
|
|
#Install a small script, that the link on the main page still works
|
|
|
|
if [ ! -f $PIRATEBOX_FOLDER/share/board/kareha.pl ] ; then
|
|
|
|
cp $PIRATEBOX_FOLDER/src/kareha.pl $PIRATEBOX_FOLDER/share/board
|
|
|
|
fi
|
2014-06-06 10:51:21 +02:00
|
|
|
|
2014-12-08 02:09:45 +01:00
|
|
|
[ ! -L $PIRATEBOX_FOLDER/www/board ] && ln -s $PIRATEBOX_FOLDER/share/board $PIRATEBOX_FOLDER/www/board
|
|
|
|
[ ! -L $PIRATEBOX_FOLDER/www/Shared ] && ln -s $UPLOADFOLDER $PIRATEBOX_FOLDER/www/Shared
|
2016-10-05 07:37:56 +02:00
|
|
|
[ ! -L $PIRATEBOX_FOLDER/www/content ] && \
|
|
|
|
ln -s $WWW_CONTENT $WWW_FOLDER/content
|
|
|
|
|
2012-04-14 16:22:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#Install the image-board
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ $1 = 'imageboard' ] ; then
|
2012-04-14 16:22:27 +02:00
|
|
|
|
2012-05-03 07:33:13 +02:00
|
|
|
if [ -e $PIRATEBOX_FOLDER/share/board/init_done ] ; then
|
2013-06-02 18:59:30 +02:00
|
|
|
echo "$PIRATEBOX_FOLDER/share/board/init_done file Found in Kareha folder. Won't reinstall board."
|
2012-05-03 07:33:13 +02:00
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
2014-04-07 08:57:45 +02:00
|
|
|
|
2012-05-02 20:25:52 +02:00
|
|
|
cd $PIRATEBOX_FOLDER/tmp
|
2013-06-05 11:04:04 +02:00
|
|
|
KAREHA_RELEASE=kareha_3.1.4.zip
|
2014-04-07 08:57:45 +02:00
|
|
|
if [ ! -e $PIRATEBOX_FOLDER/tmp/$KAREHA_RELEASE ] ; then
|
|
|
|
echo " Wgetting kareha-zip file "
|
|
|
|
wget http://wakaba.c3.cx/releases/$KAREHA_RELEASE
|
|
|
|
if [ "$?" != "0" ] ; then
|
|
|
|
echo "wget kareha failed.. you can place the current file your to $PIRATEBOX_FOLDER/tmp "
|
|
|
|
fi
|
2012-04-14 16:22:27 +02:00
|
|
|
fi
|
|
|
|
|
2013-06-05 11:04:04 +02:00
|
|
|
if [ -e $PIRATEBOX_FOLDER/tmp/$KAREHA_RELEASE ] ; then
|
2012-05-02 20:25:52 +02:00
|
|
|
echo "Kareha Zip found..."
|
|
|
|
else
|
|
|
|
echo "No Zip found, abort "
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
2013-06-05 11:04:04 +02:00
|
|
|
unzip $KAREHA_RELEASE
|
2013-06-07 11:38:10 +02:00
|
|
|
mv kareha/* $PIRATEBOX_FOLDER/share/board
|
2012-05-03 07:33:13 +02:00
|
|
|
rm -rf $PIRATEBOX_FOLDER/tmp/kareha*
|
2012-05-02 20:25:52 +02:00
|
|
|
|
2012-05-03 07:19:23 +02:00
|
|
|
cd $PIRATEBOX_FOLDER/share/board
|
|
|
|
cp -R mode_image/* ./
|
|
|
|
cp $PIRATEBOX_FOLDER/src/kareha_img_config.pl $PIRATEBOX_FOLDER/share/board/config.pl
|
2015-08-06 19:50:28 +02:00
|
|
|
cp $PIRATEBOX_FOLDER/src/no_forum.html $PIRATEBOX_FOLDER/share/board/index.htm
|
2012-05-03 07:19:23 +02:00
|
|
|
chown -R $LIGHTTPD_USER:$LIGHTTPD_GROUP $PIRATEBOX_FOLDER/share/board
|
2012-04-14 16:22:27 +02:00
|
|
|
#Install filetype thumbnails
|
2012-05-03 07:19:23 +02:00
|
|
|
mv $PIRATEBOX_FOLDER/share/board/extras/icons $PIRATEBOX_FOLDER/share/board/
|
|
|
|
|
|
|
|
echo "Errors in chown occurs if you are using vfat on the USB stick"
|
2012-05-03 07:33:13 +02:00
|
|
|
echo " . don't Panic!"
|
2012-05-03 07:19:23 +02:00
|
|
|
echo "Generating index page"
|
2013-06-07 11:11:14 +02:00
|
|
|
cd /tmp
|
|
|
|
wget -q http://127.0.0.1/board/kareha.pl
|
2012-05-03 07:19:23 +02:00
|
|
|
echo "finished!"
|
|
|
|
echo "Now Edit your kareha settings file to change your ADMIN_PASS and SECRET : "
|
2012-06-09 09:39:44 +02:00
|
|
|
echo " # vi $PIRATEBOX_FOLDER/www/board/config.pl "
|
2012-05-03 07:33:13 +02:00
|
|
|
|
|
|
|
touch $PIRATEBOX_FOLDER/share/board/init_done
|
2012-04-14 16:22:27 +02:00
|
|
|
fi
|
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ $1 = "station_cnt" ] ; then
|
2012-06-15 18:14:33 +02:00
|
|
|
#we want to append the crontab, not overwrite
|
2012-06-15 18:57:03 +02:00
|
|
|
crontab -l > $PIRATEBOX_FOLDER/tmp/crontab 2> /dev/null
|
2012-06-15 18:14:33 +02:00
|
|
|
echo "#--- Crontab for PirateBox-Station-Cnt" >> $PIRATEBOX_FOLDER/tmp/crontab
|
|
|
|
echo " */2 * * * * $PIRATEBOX_FOLDER/bin/station_cnt.sh > $WWW_FOLDER/station_cnt.txt " >> $PIRATEBOX_FOLDER/tmp/crontab
|
|
|
|
crontab $PIRATEBOX_FOLDER/tmp/crontab
|
|
|
|
[ "$?" != "0" ] && echo "an error occured" && exit 254
|
2012-06-15 18:57:03 +02:00
|
|
|
$PIRATEBOX_FOLDER/bin/station_cnt.sh > $WWW_FOLDER/station_cnt.txt
|
|
|
|
echo "installed, now every 2 minutes your station count is refreshed"
|
2012-06-12 18:01:04 +02:00
|
|
|
fi
|
2012-07-15 19:09:07 +02:00
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ $1 = "flush_dns_reg" ] ; then
|
2012-07-15 19:09:07 +02:00
|
|
|
crontab -l > $PIRATEBOX_FOLDER/tmp/crontab 2> /dev/null
|
|
|
|
echo "#--- Crontab for dnsmasq flush" >> $PIRATEBOX_FOLDER/tmp/crontab
|
|
|
|
echo " */2 * * * * $PIRATEBOX_FOLDER/bin/flush_dnsmasq.sh > $PIRATEBOX_FOLDER/tmp/dnsmasq_flush.log " >> $PIRATEBOX_FOLDER/tmp/crontab
|
|
|
|
crontab $PIRATEBOX_FOLDER/tmp/crontab
|
|
|
|
[ "$?" != "0" ] && echo "an error occured" && exit 254
|
|
|
|
echo "Installed crontab for flushing dnsmasq requlary"
|
|
|
|
fi
|
2013-06-24 11:37:38 +02:00
|
|
|
|
2013-08-19 17:13:37 +02:00
|
|
|
set_hostname() {
|
2013-06-24 11:37:38 +02:00
|
|
|
local name=$1 ; shift;
|
|
|
|
|
2013-08-15 12:50:46 +02:00
|
|
|
sed "s|#####HOST#####|$name|g" $PIRATEBOX_FOLDER/src/redirect.html.schema > $WWW_FOLDER/redirect.html
|
2013-07-01 13:28:37 +02:00
|
|
|
sed "s|HOST=\"$HOST\"|HOST=\"$name\"|" -i $PIRATEBOX_CONFIG
|
2013-06-24 11:37:38 +02:00
|
|
|
}
|
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ $1 = "hostname" ] ; then
|
|
|
|
echo "Switching hostname to $2"
|
|
|
|
set_hostname "$2"
|
2013-07-01 13:28:37 +02:00
|
|
|
echo "..done"
|
2013-08-15 12:50:46 +02:00
|
|
|
fi
|
2013-07-01 13:28:37 +02:00
|
|
|
|
2017-03-20 22:29:54 +01:00
|
|
|
if [ $1 = "content" ] ; then
|
2016-05-10 20:09:49 +02:00
|
|
|
create_content_folder
|
|
|
|
fi
|