Enhance Add colours (#21)
added colour support in a way that will not screw up the console if colour support is not available Used US spelling ;p If approved will add to remaining scripts
This commit is contained in:
parent
70a03da58f
commit
76eb530f3b
|
|
@ -1,10 +1,15 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
#move to script directory so all relative paths work
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
. resources/colors.sh
|
||||||
|
|
||||||
#Process command line options
|
#Process command line options
|
||||||
ARGS=$(getopt -n 'install.sh' -o h -l help,use-switch-source,use-switch-package-all,use-switch-master,use-switch-package-unofficial-arm,no-cpu-check -- "$@")
|
ARGS=$(getopt -n 'install.sh' -o h -l help,use-switch-source,use-switch-package-all,use-switch-master,use-switch-package-unofficial-arm,no-cpu-check -- "$@")
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed parsing options."
|
error "Failed parsing options."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -29,12 +34,12 @@ while true; do
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $HELP = true ]; then
|
if [ $HELP = true ]; then
|
||||||
echo "Debian installer script"
|
warning "Debian installer script"
|
||||||
echo " --use-switch-source will use freeswitch from source rather than (default:packages)"
|
warning " --use-switch-source will use freeswitch from source rather than ${green}(default:packages)"
|
||||||
echo " --use-switch-package-all if using packages use the meta-all package"
|
warning " --use-switch-package-all if using packages use the meta-all package"
|
||||||
echo " --use-switch-package-unofficial-arm if your system is arm and you are using packages, use the unofficial arm repo"
|
warning " --use-switch-package-unofficial-arm if your system is arm and you are using packages, use the unofficial arm repo"
|
||||||
echo " --use-switch-master will use master branch/packages instead of (default:stable)"
|
warning " --use-switch-master will use master branch/packages instead of ${green}(default:stable)"
|
||||||
echo " --no-cpu-check disable the cpu check (default:check)"
|
warning " --no-cpu-check disable the cpu check ${green}(default:check)"
|
||||||
exit;
|
exit;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -50,17 +55,17 @@ if [ $CPU_CHECK = true ]; then
|
||||||
if [ $USE_SWITCH_SOURCE = false ]; then
|
if [ $USE_SWITCH_SOURCE = false ]; then
|
||||||
if [ $OS_arch = 'armv7l' ]; then
|
if [ $OS_arch = 'armv7l' ]; then
|
||||||
if [ $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM = false && OS_bits = 'i686' ]; then
|
if [ $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM = false && OS_bits = 'i686' ]; then
|
||||||
echo "You are using a 32bit arm OS this is unsupported"
|
error "You are using a 32bit arm OS this is unsupported"
|
||||||
echo " please rerun with either --use-switch-package-unofficial-arm or --use-switch-source"
|
warning " please rerun with either --use-switch-package-unofficial-arm or --use-switch-source"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ $OS_bits = 'i686' ]; then
|
if [ $OS_bits = 'i686' ]; then
|
||||||
echo "You are using a 32bit OS this is unsupported"
|
error "You are using a 32bit OS this is unsupported"
|
||||||
if [ $CPU_bits = 'x86_64' ]; then
|
if [ $CPU_bits = 'x86_64' ]; then
|
||||||
echo "Your CPU is 64bit you should consider reinstalling with a 64bit OS"
|
error "Your CPU is 64bit you should consider reinstalling with a 64bit OS"
|
||||||
fi
|
fi
|
||||||
echo " please rerun with --use-switch-source"
|
warning " please rerun with --use-switch-source"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
@ -71,12 +76,9 @@ fi
|
||||||
sed -i '/cdrom:/d' /etc/apt/sources.list
|
sed -i '/cdrom:/d' /etc/apt/sources.list
|
||||||
|
|
||||||
#Update Debian
|
#Update Debian
|
||||||
echo "Update Debian"
|
verbose "Update Debian"
|
||||||
apt-get upgrade && apt-get update -y --force-yes
|
apt-get upgrade && apt-get update -y --force-yes
|
||||||
|
|
||||||
#move to script directory so all relative paths work
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
#IPTables
|
#IPTables
|
||||||
resources/iptables.sh
|
resources/iptables.sh
|
||||||
|
|
||||||
|
|
@ -129,8 +131,8 @@ systemctl restart nginx
|
||||||
systemctl restart fail2ban
|
systemctl restart fail2ban
|
||||||
|
|
||||||
#Show database password
|
#Show database password
|
||||||
echo "Complete the install by by going to the IP address of this server ";
|
verbose "Complete the install by by going to the IP address of this server ";
|
||||||
echo "in your web browser or with a domain name for this server.";
|
verbose "in your web browser or with a domain name for this server.";
|
||||||
echo " https://$server_address"
|
echo " https://$server_address"
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
verbose () {
|
||||||
|
echo "${green}$1${normal}"
|
||||||
|
}
|
||||||
|
error () {
|
||||||
|
echo "${red}$1${normal}"
|
||||||
|
}
|
||||||
|
warning () {
|
||||||
|
echo "${yellow}$1${normal}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# check for color support
|
||||||
|
if test -t 1; then
|
||||||
|
|
||||||
|
# see if it supports colors...
|
||||||
|
ncolors=$(tput colors)
|
||||||
|
|
||||||
|
if test -n "$ncolors" && test $ncolors -ge 8; then
|
||||||
|
normal="$(tput sgr0)"
|
||||||
|
red="$(tput setaf 1)"
|
||||||
|
green="$(tput setaf 2)"
|
||||||
|
yellow="$(tput setaf 3)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
55
install.sh
55
install.sh
|
|
@ -4,12 +4,44 @@
|
||||||
# 2 unsupported OS
|
# 2 unsupported OS
|
||||||
# 3 unsupported CPU/OS bits
|
# 3 unsupported CPU/OS bits
|
||||||
|
|
||||||
|
verbose () {
|
||||||
|
echo "${green}$1${normal}"
|
||||||
|
}
|
||||||
|
error () {
|
||||||
|
echo "${red}$1${normal}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# check for color support
|
||||||
|
if test -t 1; then
|
||||||
|
|
||||||
|
# see if it supports colors...
|
||||||
|
ncolors=$(tput colors)
|
||||||
|
|
||||||
|
if test -n "$ncolors" && test $ncolors -ge 8; then
|
||||||
|
bold="$(tput bold)"
|
||||||
|
underline="$(tput smul)"
|
||||||
|
standout="$(tput smso)"
|
||||||
|
normal="$(tput sgr0)"
|
||||||
|
black="$(tput setaf 0)"
|
||||||
|
red="$(tput setaf 1)"
|
||||||
|
green="$(tput setaf 2)"
|
||||||
|
yellow="$(tput setaf 3)"
|
||||||
|
blue="$(tput setaf 4)"
|
||||||
|
magenta="$(tput setaf 5)"
|
||||||
|
cyan="$(tput setaf 6)"
|
||||||
|
white="$(tput setaf 7)"
|
||||||
|
fi
|
||||||
|
verbose "Enabled color support"
|
||||||
|
fi
|
||||||
|
|
||||||
# check to confirm running as root.
|
# check to confirm running as root.
|
||||||
if [ "$(id -u)" -ne "0" ]; then
|
if [ "$(id -u)" -ne "0" ]; then
|
||||||
echo "$(basename "$0") must be run as root";
|
error "$(basename "$0") must be run as root";
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo
|
|
||||||
|
#Make ourselves executable next time we are run
|
||||||
|
chmod +x $0
|
||||||
|
|
||||||
#Os/Distro Check
|
#Os/Distro Check
|
||||||
os_check=$(lsb_release -is)
|
os_check=$(lsb_release -is)
|
||||||
|
|
@ -18,29 +50,30 @@ check_major_release=$(lsb_release -rs | cut -d. -f1)
|
||||||
os_unsupported () {
|
os_unsupported () {
|
||||||
echo " Your Operating System appears to be: "
|
echo " Your Operating System appears to be: "
|
||||||
lsb_release -a
|
lsb_release -a
|
||||||
echo "Your Operating System is not currently supported... Exiting the install."
|
error "Your Operating System is not currently supported... Exiting the install."
|
||||||
exit 2;
|
exit 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $os_check = 'Debian' ]; then
|
if [ $os_check = 'Debian' ]; then
|
||||||
if [ $check_major_release -ge 8 ]; then
|
if [ $check_major_release -ge 8 ]; then
|
||||||
echo "Removing the CD image from /etc/apt/sources.list"
|
verbose "Removing the CD image from /etc/apt/sources.list"
|
||||||
sed -i '/cdrom:/d' /etc/apt/sources.list
|
sed -i '/cdrom:/d' /etc/apt/sources.list
|
||||||
echo "Updating system before starting."
|
verbose "Updating system before starting."
|
||||||
apt-get update && apt-get -y upgrade
|
apt-get update && apt-get -y upgrade
|
||||||
echo "Installing Git"
|
verbose "Installing Git"
|
||||||
apt-get install -y git
|
apt-get install -y git
|
||||||
cd /usr/src
|
cd /usr/src
|
||||||
echo "Fetching Installer"
|
verbose "Fetching Installer"
|
||||||
if [ -d /usr/src/fusionpbx-install.sh ]; then
|
if [ -d /usr/src/fusionpbx-install.sh ]; then
|
||||||
echo "Cannot continue you already have a installer downloaded"
|
cd /usr/src/fusionpbx-install.sh
|
||||||
exit 1
|
git pull
|
||||||
|
else
|
||||||
|
git clone https://github.com/fusionpbx/fusionpbx-install.sh
|
||||||
fi
|
fi
|
||||||
git clone https://github.com/fusionpbx/fusionpbx-install.sh
|
|
||||||
cd /usr/src/fusionpbx-install.sh/debian
|
cd /usr/src/fusionpbx-install.sh/debian
|
||||||
./install.sh $@
|
./install.sh $@
|
||||||
else
|
else
|
||||||
echo "Although you are running Debian we require version >= 8"
|
error "Although you are running Debian we require version >= 8"
|
||||||
os_unsupported
|
os_unsupported
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue