#!/bin/bash PROG_NAME="$(basename $0)" ARGS="$@" VERSION="4.9-1.2.0" function print_version() { printf "\tPi-Tail Installer: $PROG_NAME $VERSION\n\n" exit 0 } function print_help() { printf "\n\tUsage: ${PROG_NAME} [option]\n" printf "\t\t\t (No option)\tInstall Pi-Tail\n" printf "\t\t\t\t-h\tPrint this help\n" printf "\t\t\t\t-v\tPrint version of this installer\n" printf "\t\t\t\t-u\tUpgrade Pi-Tail to its latest version\n\n" printf "\t\t\t\t-i\tUpdate this installer\n\n" exit 1 } function ask() { # http://djm.me/ask while true; do if [ "${2:-}" = "Y" ]; then prompt="Y/n" default=Y elif [ "${2:-}" = "N" ]; then prompt="y/N" default=N else prompt="y/n" default= fi # Ask the question printf "\t++++ " read -p "$1 [$prompt] " REPLY # Default? if [ -z "$REPLY" ]; then REPLY=$default fi # Check if the reply is valid case "$REPLY" in Y*|y*) return 0 ;; N*|n*) return 1 ;; esac done } function exitonerr { # via: http://stackoverflow.com/a/5196108 "$@" local status=$? if [ $status -ne 0 ]; then echo "Error completing: $1" >&2 exit 1 fi return $status } function update_installer() { TEMP_FILE="/tmp/install.pi-tail" printf "\n\t*** Downloading update ***\n" wget -O ${TEMP_FILE} https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/install.pi-tail cp -f $TEMP_FILE /usr/local/bin/$PROG_NAME chmod +x /usr/local/bin/$PROG_NAME rm -f $TEMP_FILE printf "\tReplaced old version:\tRe4son-Kernel Installer: ${PROG_NAME} ${VERSION}\n" printf "\tWith new version:" source "/usr/local/bin/$PROG_NAME" -v exit 0 } function check_root() { if [[ $EUID -ne 0 ]]; then printf "\n\t${PROG_NAME} must be run as root. try: sudo install.sh\n\n" exit 1 fi } function install() { printf "\t**** Installing Pi-Tail ****\n\n" wget -O /etc/systemd/system/pi-tail.service https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/pi-tail.service wget -O /etc/systemd/system/pi-tailbt.service https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/pi-tailbt.service wget -O /etc/systemd/system/pi-tailms.service https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/pi-tailms.service wget -O /etc/systemd/system/pi-tailap.service https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/pi-tailap.services wget -O /etc/systemd/network/pan0.network https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/pan0.network wget -O /etc/systemd/system/bt-agent.service https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/bt-agent.service wget -O /etc/systemd/system/bt-network.service https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/bt-network.service wget -O /lib/systemd/system/hciuart.service https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/hciuart.service wget -O /boot/cmdline.txt https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/cmdline.storage wget -O /boot/cmdline.storage https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/cmdline.storage wget -O /boot/cmdline.eth https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/cmdline.eth wget -O /boot/interfaces https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/interfaces wget -O /boot/interfaces.example.wifi https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/interfaces.example.wifi wget -O /boot/interfaces.example.wifi-AP https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/interfaces.example.wifi-AP wget -O /boot/pi-tailbt.example https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/pi-tailbt.example wget -O /boot/wpa_supplicant.conf https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/wpa_supplicant.conf wget -O /boot/Pi-Tail.README https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/Pi-Tail.README wget -O /boot/Pi-Tail.HOWTO https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/Pi-Tail.HOWTO wget -O /boot/config.txt https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/config.txt wget -O /etc/udev/rules.d/70-persistent-net.rules https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/70-persistent-net.rules wget -O /opt/Kali-Pi/Menus/RAS-AP/dnsmasq-dhcpd.conf https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/dnsmasq-dhcpd.conf wget -O /opt/Kali-Pi/Menus/RAS-AP/ras-ap.sh https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/ras-ap.sh wget -O /opt/Kali-Pi/Menus/RAS-AP/ras-ap.conf https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/ras-ap.conf wget -O /usr/local/bin/mon0up https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/mon0up wget -O /usr/local/bin/mon0down https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/mon0down wget -O /usr/local/bin/setgw https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/setgw wget -O /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/nodnsupdate wget -O /tmp/resolv.conf https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/resolv.conf cp -f /tmp/resolv.conf /etc/resolv.conf chmod 755 /usr/local/bin/mon0up /usr/local/bin/mon0down /usr/local/bin/setgw /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate printf "\t**** Enabling services ****\n\n" systemctl enable pi-tail.service && systemctl enable pi-tailbt.service && systemctl enable pi-tailms.service && systemctl enable pi-tailap.service && systemctl enable systemd-networkd && systemctl enable bt-agent && systemctl enable bt-network printf "\t**** Installation completed ****\n\n" } function upgrade() { printf "\t**** Upgrading Pi-Tail ****\n\n" wget -O /boot/Pi-Tail.HOWTO https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/Pi-Tail.HOWTO wget -O /opt/Kali-Pi/Menus/RAS-AP/ras-ap.sh https://raw.githubusercontent.com/Re4son/RPi-Tweaks/master/pi-tail/ras-ap.sh chmod 755 /opt/Kali-Pi/Menus/RAS-AP/ras-ap.sh printf "\t**** Upgrade completed ****\n\n" } ############ ## ## ## MAIN ## args=$(getopt -uo 'hvui' -- $*) set -- $args for i do case "$i" in -h) print_help exit 0 ;; -v) print_version exit 0 ;; -u) check_root upgrade exit 0 ;; -i) check_root update_installer exit 0 ;; esac done check_root install if ask "Reboot to apply changes?" "Y"; then reboot fi printf "\n" exit 0