a2server/scripts/a2server-2-tools.txt
Ivan X 01d3ce1775 libdb5.3+libgcrypt20 on Jessie rather than installing older Wheezy libs
removed libdb4.8 support
fixed source URL's to use external/source when locally hosting externals
2015-12-25 12:37:56 +09:00

200 lines
6.7 KiB
Bash
Executable File

#! /bin/bash
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
# download and install a2server tools:
# mkatinit, mkvolinfo, afptype, afpsync, aliases, nulib2
# Ensure URL we'll use ends in a /
case "$A2SERVER_SCRIPT_URL" in
*/) scriptURL="$A2SERVER_SCRIPT_URL" ;;
*) scriptURL="${A2SERVER_SCRIPT_URL:-http://ivanx.com/a2server}/" ;;
esac
case "$A2SERVER_BINARY_URL" in
*/) binaryURL="$A2SERVER_BINARY_URL" ;;
*) binaryURL="${A2SERVER_BINARY_URL:-http://ivanx.com/a2server/files}/" ;;
esac
useExternalURL=1
[[ $A2SERVER_NO_EXTERNAL ]] && useExternalURL=
debianVersion=$(cat /etc/debian_version 2> /dev/null)
isRpi=
arch=
if [[ -f /usr/bin/raspi-config ]]; then
isRpi=1
arch='rpi'
elif lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian' && [[ $(cut -c 1 <<< $debianVersion) -ge "7" ]]; then
uname_m="$(uname -m)"
if [[ $uname_m == "i686" ]]; then
arch='debian_x86'
elif [[ $uname_m == "x86_64" ]]; then
arch='debian_x64'
fi
fi
debianName=
if [[ $debianVersion ]]; then
debianMajor=$(cut -c 1-2 <<< $debianVersion)
if [[ $debianMajor == "8." ]]; then
debianName="jessie"
elif [[ $debianMajor == "7." ]]; then
debianName="wheezy"
else
debianName="unknown"
fi
fi
echo "A2SERVER: Installing A2SERVER tools..."
if ! command -v nulib2 > /dev/null; then
echo "A2SERVER: Installing nulib2..."
cd /tmp
if [[ $arch ]]; then
{ wget -qO- "${binaryURL}precompiled/nulib2-${arch}.tgz" | sudo tar Pzx; } &> /dev/null
fi
if ! command -v nulib2 > /dev/null; then
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
# prepare for installing packages
sudo apt-get -y update
touch /tmp/a2server-packageReposUpdated
fi
# Dependencies: build-dep for nulib
sudo apt-get -y install build-essential zlib1g-dev
sudo apt-get -y clean
cd /tmp
rm -rf /tmp/nulib &> /dev/null
mkdir /tmp/nulib
cd /tmp/nulib
if [[ $useExternalURL ]]; then
wget -q -O nulibdist.tar.gz http://web.archive.org/web/20131031160750/http://www.nulib.com/downloads/nulibdist.tar.gz
tar zxf nulibdist.tar.gz &> /dev/null
fi
if [[ ! -d nulib2-220 ]]; then
wget -q -O nulibdist.tar.gz ${binaryURL}external/source/nulibdist.tar.gz
tar zxf nulibdist.tar.gz &> /dev/null
fi
cd nufxlib*
./configure
make
sudo make install
cd ../nulib2*
./configure
make
sudo make install
cd
rm -rf /tmp/nulib
fi
else
echo "A2SERVER: Nulib2 has already been installed."
fi
# download and install The Unarchiver, for expanding Apple disk images
# http://wakaba.c3.cx/s/apps/unarchiver.html
if ! command -v unar > /dev/null; then
echo "A2SERVER: Installing The Unarchiver..."
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
# prepare for installing packages
sudo apt-get -y update
touch /tmp/a2server-packageReposUpdated
fi
# jessie and later: Just use the unar package
if [[ $debianName == "jessie" ]]; then
sudo apt-get -y install unar
sudo apt-get clean
fi
if ! command -v unar > /dev/null; then
if [[ $arch ]]; then
# Dependencies: for unar
sudo apt-get -y install libgnustep-base1.22
sudo apt-get clean
{ wget -qO- "${binaryURL}precompiled/unar-${arch}_${debianName}.tgz" | sudo tar Pzx; } &> /dev/null
fi
# If all else fails, compile from source.
if ! command -v unar >/dev/null; then
# Dependencies: build-deps for unar
sudo apt-get -y install build-essential libgnustep-base-dev libz-dev libbz2-dev libssl-dev libicu-dev unzip
sudo apt-get clean
rm -rf /tmp/unar &> /dev/null
mkdir /tmp/unar
cd /tmp/unar
if [[ $useExternalURL ]]; then
wget -O unar_1.8.zip https://github.com/incbee/Unarchiver/archive/unar-1.8.zip
unzip -o unar_1.8.zip &> /dev/null
fi
if [ ! -d *Unarchiver*/XADMaster ]; then # need single bracket for glob
wget -O unar_1.8.zip ${binaryURL}external/source/unar-1.8.zip
unzip -o unar_1.8.zip &> /dev/null
fi
cd *Unarchiver*/XADMaster
make -f Makefile.linux
sudo mv lsar unar /usr/local/bin
cd ../Extra
sudo mv lsar.1 unar.1 /usr/local/man/man1
cd
rm -rf /tmp/unar
fi
sudo mandb &> /dev/null
fi
else
echo "A2SERVER: The Unarchiver has already been installed."
fi
if ! command -v unzip >/dev/null; then
echo "A2SERVER: Installing unzip..."
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
# prepare for installing packages
sudo apt-get -y update
touch /tmp/a2server-packageReposUpdated
fi
# Dependencies: unzip
sudo apt-get -y install unzip
sudo apt-get clean
else
echo "A2SERVER: unzip has already been installed."
fi
sudo wget -q -O /usr/local/bin/afpsync "${scriptURL}scripts/tools/afpsync.txt"
sudo chmod ugo+x /usr/local/bin/afpsync
sudo wget -q -O /usr/local/bin/afptype "${scriptURL}scripts/tools/afptype.txt"
sudo chmod ugo+x /usr/local/bin/afptype
sudo wget -q -O /usr/local/bin/mkatinit "${scriptURL}scripts/tools/mkatinit.txt"
sudo chmod ugo+x /usr/local/bin/mkatinit
sudo wget -q -O /usr/local/bin/mkvolinfo "${scriptURL}scripts/tools/mkvolinfo.txt"
sudo chmod ugo+x /usr/local/bin/mkvolinfo
sudo wget -q -O /usr/local/bin/cppo "${scriptURL}scripts/tools/cppo.txt"
sudo chmod ugo+x /usr/local/bin/cppo
sudo wget -q -O /usr/local/etc/a2server-help.txt "${scriptURL}scripts/tools/a2server-help.txt"
sudo wget -q -O /usr/local/etc/a2server-aliases "${scriptURL}scripts/tools/a2server-aliases.txt"
sudo wget -q -O /usr/local/etc/a2serverrc "${scriptURL}scripts/tools/a2serverrc.txt"
# 1.3.0: a2serverrc is now called from /etc/bash.bashrc,
# which in turn calls a2server-aliases
grep 'a2server-aliases' /etc/bash.bashrc > /dev/null && \
sudo sed -i 's/a2server-aliases/a2serverrc/' /etc/bash.bashrc
grep 'a2serverrc' /etc/bash.bashrc > /dev/null || \
echo "source /usr/local/etc/a2serverrc" | sudo tee -a /etc/bash.bashrc > /dev/null
motd="/etc/motd"
if [[ ! $(grep A2SERVER $motd) ]]; then
echo | sudo tee -a $motd > /dev/null
echo "Type 'system-shutdown' to turn off A2SERVER." | sudo tee -a $motd > /dev/null
echo "Type 'a2server-setup' to configure network boot." | sudo tee -a $motd > /dev/null
echo "Type 'a2server-help' for a list of other commands." | sudo tee -a $motd > /dev/null
echo | sudo tee -a $motd > /dev/null
fi