2013-01-31 21:38:55 +01:00
|
|
|
#!/bin/bash
|
2013-02-02 22:11:29 +01:00
|
|
|
#=======================================================================
|
|
|
|
#
|
|
|
|
# FILE: install.sh
|
|
|
|
#
|
|
|
|
# USAGE: ./install.sh
|
|
|
|
#
|
|
|
|
# DESCRIPTION: Install file for PirateBox.
|
|
|
|
#
|
|
|
|
# OPTIONS: ./install.sh <default|board> <optional: USB path>
|
|
|
|
# REQUIREMENTS: ---
|
2013-02-03 00:35:17 +01:00
|
|
|
# BUGS: Link from install
|
2013-02-02 22:11:29 +01:00
|
|
|
# NOTES: ---
|
|
|
|
# AUTHOR: Cale 'TerrorByte' Black, cablack@rams.colostate.edu
|
|
|
|
# COMPANY: ---
|
2013-02-03 03:51:08 +01:00
|
|
|
# CREATED: 02.02.2013 19:50:34 MST
|
|
|
|
# REVISION: 0.3.1
|
2013-02-02 22:11:29 +01:00
|
|
|
#=======================================================================
|
2013-02-06 15:19:23 +01:00
|
|
|
#Import PirateBox conf
|
2013-02-02 22:11:29 +01:00
|
|
|
CURRENT_CONF=piratebox/piratebox/conf/piratebox.conf
|
2013-02-06 15:19:23 +01:00
|
|
|
|
|
|
|
#Must be root
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "This script must be run as root" #1>&2
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2013-02-03 00:35:17 +01:00
|
|
|
if [[ $1 ]]; then
|
2013-02-02 22:11:29 +01:00
|
|
|
echo "Installing..."
|
|
|
|
else
|
2013-02-03 00:35:17 +01:00
|
|
|
echo "Useage: /bin/bash install.sh <default|board>"
|
2013-02-02 22:11:29 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
2013-01-31 21:38:55 +01:00
|
|
|
|
2013-02-02 22:11:29 +01:00
|
|
|
if [[ -f $CURRENT_CONF ]]; then
|
|
|
|
. $CURRENT_CONF 2> /dev/null
|
|
|
|
else
|
|
|
|
echo "PirateBox config is not in its normal directory"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#begin setting up piratebox's home dir
|
2013-02-06 16:26:30 +01:00
|
|
|
if [[ ! -d /opt ]]; then
|
|
|
|
mkdir -p /opt
|
2013-02-02 22:11:29 +01:00
|
|
|
fi
|
|
|
|
|
2013-02-06 16:26:30 +01:00
|
|
|
cp -rv piratebox/piratebox /opt &> /dev/null
|
|
|
|
echo "Finished copying files..."
|
|
|
|
echo "$NET.$IP_SHORT piratebox.lan">>/etc/hosts
|
|
|
|
echo "$NET.$IP_SHORT piratebox">>/etc/hosts
|
|
|
|
|
2013-02-04 19:59:13 +01:00
|
|
|
if [[ -d /etc/init.d/ ]]; then
|
|
|
|
ln -s /opt/piratebox/init.d/piratebox /etc/init.d/piratebox
|
|
|
|
update-rc.d piratebox defaults
|
2013-02-03 03:51:08 +01:00
|
|
|
# systemctl enable piratebox #This enables PirateBox at start up... could be useful for Live
|
2013-02-02 22:11:29 +01:00
|
|
|
else
|
|
|
|
#link between opt and etc/pb
|
2013-02-04 19:59:13 +01:00
|
|
|
ln -s /opt/piratebox/init.d/piratebox.service /etc/systemd/system/piratebox.service
|
2013-02-02 22:11:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#install dependencies
|
|
|
|
#TODO missing anything in $DEPENDENCIES?
|
|
|
|
# Modified Script by martedì at http://www.mirkopagliai.it/bash-scripting-check-for-and-install-missing-dependencies/
|
2013-02-03 00:35:17 +01:00
|
|
|
#DEPENDENCIES=(hostapd lighttpd dnsmasq)
|
|
|
|
PKGSTOINSTALL="hostapd lighttpd dnsmasq"
|
|
|
|
#PKG=( $PKGSTOINSTALL )
|
2013-02-02 22:11:29 +01:00
|
|
|
|
2013-02-03 00:35:17 +01:00
|
|
|
#if [[ ! `dpkg -l | grep -w "ii ${DEPENDENCIES[$i]} "` ]]; then
|
2013-02-02 22:11:29 +01:00
|
|
|
|
|
|
|
# If some dependencies are missing, asks if user wants to install
|
|
|
|
if [ "$PKGSTOINSTALL" != "" ]; then
|
2013-02-03 00:35:17 +01:00
|
|
|
echo -n "Some dependencies may missing. Would you like to install them? (Y/n): "
|
2013-02-02 22:11:29 +01:00
|
|
|
read SURE
|
|
|
|
# If user want to install missing dependencies
|
|
|
|
if [[ $SURE = "Y" || $SURE = "y" || $SURE = "" ]]; then
|
|
|
|
# Debian, Ubuntu and derivatives (with apt-get)
|
|
|
|
if which apt-get &> /dev/null; then
|
|
|
|
apt-get install $PKGSTOINSTALL
|
|
|
|
# OpenSuse (with zypper)
|
2013-02-03 00:35:17 +01:00
|
|
|
#elif which zypper &> /dev/null; then
|
|
|
|
# zypper in $PKGSTOINSTALL
|
2013-02-02 22:11:29 +01:00
|
|
|
# Mandriva (with urpmi)
|
|
|
|
elif which urpmi &> /dev/null; then
|
|
|
|
urpmi $PKGSTOINSTALL
|
|
|
|
# Fedora and CentOS (with yum)
|
|
|
|
elif which yum &> /dev/null; then
|
|
|
|
yum install $PKGSTOINSTALL
|
|
|
|
# ArchLinux (with pacman)
|
|
|
|
elif which pacman &> /dev/null; then
|
|
|
|
pacman -Sy $PKGSTOINSTALL
|
|
|
|
# Else, if no package manager has been found
|
|
|
|
else
|
|
|
|
# Set $NOPKGMANAGER
|
|
|
|
NOPKGMANAGER=TRUE
|
2013-02-03 00:35:17 +01:00
|
|
|
echo "ERROR: No package manager found. Please, manually install: $PKGSTOINSTALL."
|
2013-02-02 22:11:29 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#install piratebox with the given option
|
|
|
|
case "$1" in
|
|
|
|
default)
|
|
|
|
/opt/piratebox/bin/install_piratebox.sh /opt/piratebox/conf/piratebox.conf part2
|
|
|
|
;;
|
|
|
|
board)
|
|
|
|
/opt/piratebox/bin/install_piratebox.sh /opt/piratebox/conf/piratebox.conf imageboard
|
2013-02-03 00:35:17 +01:00
|
|
|
echo "############################################################################"
|
|
|
|
echo "#Edit /opt/piratebox/share/board/config.pl and change ADMIN_PASS and SECRET#"
|
|
|
|
echo "############################################################################"
|
2013-02-02 22:11:29 +01:00
|
|
|
;;
|
|
|
|
*)
|
2013-02-03 00:35:17 +01:00
|
|
|
echo "$1 is not an option. Useage: /bin/bash install.sh <default|board>"
|
2013-02-02 22:11:29 +01:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2013-02-03 00:35:17 +01:00
|
|
|
#if [[ -n $2 ]]; then
|
|
|
|
# ln -s $2 /opt/piratebox/share
|
|
|
|
# echo "Files placed on $2 will be shared"
|
|
|
|
# echo "In order to change this remove the symlink between $2 and /opt/piratebox/share"
|
|
|
|
#else
|
|
|
|
# echo "USB not found, not creating a link between the PirateBox share folder and the USB drive"
|
|
|
|
# echo "If you want to create a link between a USB drive and the share folder then run piratebox link '<USB Drive full path>'"
|
|
|
|
#fi`
|
2013-02-02 22:11:29 +01:00
|
|
|
|
|
|
|
echo "##############################"
|
|
|
|
echo "#PirateBox has been installed#"
|
|
|
|
echo "##############################"
|
|
|
|
echo ""
|
2013-02-03 05:33:09 +01:00
|
|
|
echo "Use: service piratebox <start|stop>"
|
|
|
|
echo "or for systemd systems Use: systemctl <start|stop|restart> piratebox"
|
2013-02-03 00:35:17 +01:00
|
|
|
exit 0
|