Add script 'install-debian-perl-requirements.sh'.
This commit is contained in:
317
install-debian-perl-requirements.sh
Executable file
317
install-debian-perl-requirements.sh
Executable file
@@ -0,0 +1,317 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
working_dir="$(dirname $(realpath $0))"
|
||||
script_name="$(basename $(realpath $0))"
|
||||
|
||||
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
|
||||
|
||||
_src_base_dir="$working_dir"
|
||||
#conf_file="${_src_base_dir}/conf/install_sympa.conf"
|
||||
|
||||
backup_date="$(date +%Y-%m-%d-%H%M)"
|
||||
|
||||
err_log="$(mktemp)"
|
||||
|
||||
|
||||
|
||||
## --- some functions
|
||||
## ---
|
||||
clean_up() {
|
||||
|
||||
# Perform program exit housekeeping
|
||||
rm -f "$err_log"
|
||||
exit $1
|
||||
}
|
||||
|
||||
echononl(){
|
||||
echo X\\c > /tmp/shprompt$$
|
||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||
echo -e -n "$*\\c" 1>&2
|
||||
else
|
||||
echo -e -n "$*" 1>&2
|
||||
fi
|
||||
rm /tmp/shprompt$$
|
||||
}
|
||||
|
||||
fatal(){
|
||||
echo ""
|
||||
echo -e "\t[ \033[31m\033[1mError\033[m ]: $*"
|
||||
echo ""
|
||||
echo -e "\t\033[31m\033[1mInstalllation is canceled\033[m\033[m"
|
||||
echo ""
|
||||
clean_up 1
|
||||
}
|
||||
|
||||
warn (){
|
||||
echo ""
|
||||
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
|
||||
echo ""
|
||||
}
|
||||
|
||||
info (){
|
||||
echo ""
|
||||
echo -e "\t[ \033[33m\033[1mInfo\033[m ]: $*"
|
||||
echo ""
|
||||
}
|
||||
|
||||
ok (){
|
||||
echo ""
|
||||
echo -e "\t[ \033[36m\033[1mOk\033[m ]: $*"
|
||||
echo ""
|
||||
}
|
||||
|
||||
error(){
|
||||
echo ""
|
||||
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
|
||||
echo ""
|
||||
}
|
||||
|
||||
echo_ok() {
|
||||
echo -e "\033[75G[ \033[32mok\033[m ]"
|
||||
}
|
||||
echo_failed(){
|
||||
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
|
||||
}
|
||||
echo_skipped() {
|
||||
echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]"
|
||||
}
|
||||
echo_wait(){
|
||||
echo -en "\033[75G[ \033[5m\033[1mwait\033[m ]"
|
||||
}
|
||||
|
||||
detect_os_1 () {
|
||||
|
||||
if $(which lsb_release > /dev/null 2>&1) ; then
|
||||
|
||||
os_dist="$(lsb_release -i | awk '{print tolower($3)}')"
|
||||
os_version="$(lsb_release -r | awk '{print tolower($2)}')"
|
||||
os_codename="$(lsb_release -c | awk '{print tolower($2)}')"
|
||||
|
||||
if [[ "$os_dist" = "debian" ]]; then
|
||||
if $(echo "$os_version" | grep -q '\.') ; then
|
||||
os_version=$(echo "$os_version" | cut --delimiter='.' -f1)
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [[ -e "/etc/os-release" ]]; then
|
||||
|
||||
. /etc/os-release
|
||||
|
||||
os_dist=$ID
|
||||
os_version=${VERSION_ID}
|
||||
|
||||
fi
|
||||
|
||||
# remove whitespace from os_dist and os_version
|
||||
os_dist="${os_dist// /}"
|
||||
os_version="${os_version// /}"
|
||||
|
||||
}
|
||||
|
||||
## ---
|
||||
## --- END: functions
|
||||
|
||||
trap clean_up SIGHUP SIGINT SIGTERM
|
||||
|
||||
_required_debian_packages="
|
||||
build-essential
|
||||
ca-certificates
|
||||
cpanminus
|
||||
libarchive-zip-perl
|
||||
libauthcas-perl
|
||||
libcgi-fast-perl
|
||||
libcgi-pm-perl
|
||||
libclass-singleton-perl
|
||||
libcrypt-openssl-x509-perl
|
||||
libcrypt-smime-perl
|
||||
libdata-password-perl
|
||||
libdatetime-format-mail-perl
|
||||
libdatetime-timezone-perl
|
||||
libdbd-csv-perl
|
||||
libdbd-mysql-perl
|
||||
libdbd-pg-perl
|
||||
libdbd-sqlite3-perl
|
||||
libdbd-sybase-perl
|
||||
libdbi-perl
|
||||
libdbi-test-perl
|
||||
libfcgi-perl
|
||||
libfile-copy-recursive-perl
|
||||
libfile-nfslock-perl
|
||||
libhtml-format-perl
|
||||
libhtml-stripscripts-parser-perl
|
||||
libhtml-tree-perl
|
||||
libintl-perl
|
||||
libio-socket-ssl-perl
|
||||
libio-stringy-perl
|
||||
libmail-dkim-perl
|
||||
libmail-sendmail-perl
|
||||
libmailtools-perl
|
||||
libmime-base64-perl
|
||||
libmime-charset-perl
|
||||
libmime-encwords-perl
|
||||
libmime-lite-html-perl
|
||||
libmime-tools-perl
|
||||
libmsgcat-perl
|
||||
libnet-ldap-perl
|
||||
libnet-netmask-perl
|
||||
libproc-processtable-perl
|
||||
libregexp-common-perl
|
||||
libsoap-lite-perl
|
||||
libtemplate-perl
|
||||
libterm-progressbar-perl
|
||||
libunicode-linebreak-perl
|
||||
libutf8-all-perl
|
||||
libxml-libxml-perl
|
||||
lsb-base
|
||||
mhonarc
|
||||
perl-modules
|
||||
spawn-fcgi
|
||||
unixodbc
|
||||
unixodbc-dev
|
||||
"
|
||||
|
||||
if [[ "$os_dist" = "debian" ]] && [[ $os_version -lt 13 ]] ; then
|
||||
_required_debian_packages="${_required_debian_packages}
|
||||
libdbd-odbc-perl"
|
||||
fi
|
||||
|
||||
_needed_cpan_modules="
|
||||
CPAN
|
||||
Archive::Zip
|
||||
CGI
|
||||
Class::Singleton
|
||||
DBD::mysql
|
||||
DBI
|
||||
DateTime::Format::Mail
|
||||
DateTime::TimeZone
|
||||
Digest::MD5
|
||||
Encode
|
||||
File::Copy::Recursive
|
||||
File::NFSLock
|
||||
File::Path
|
||||
HTML::FormatText
|
||||
HTML::StripScripts::Parser
|
||||
HTML::TreeBuilder
|
||||
IO::File
|
||||
IO::Scalar
|
||||
LWP::UserAgent
|
||||
List::Util::XS
|
||||
Locale::Messages
|
||||
MHonArc::UTF8
|
||||
MIME::Base64
|
||||
MIME::Charset
|
||||
MIME::EncWords
|
||||
MIME::Lite::HTML
|
||||
MIME::Tools
|
||||
Mail::Address
|
||||
Net::CIDR
|
||||
Net::DNS
|
||||
Sys::Syslog
|
||||
Template
|
||||
Term::ProgressBar
|
||||
Text::LineFold
|
||||
Time::HiRes
|
||||
URI::Escape
|
||||
XML::LibXML
|
||||
AuthCAS
|
||||
CGI::Fast
|
||||
Clone
|
||||
Crypt::CipherSaber
|
||||
Crypt::OpenSSL::X509
|
||||
Crypt::SMIME
|
||||
DBD::CSV
|
||||
DBD::ODBC
|
||||
DBD::Pg
|
||||
DBD::SQLite
|
||||
DBD::Sybase
|
||||
Data::Password
|
||||
Encode::Locale
|
||||
FCGI
|
||||
IO::Socket::SSL
|
||||
Mail::DKIM::Verifier
|
||||
Net::DNS
|
||||
Net::LDAP
|
||||
Net::SMTP
|
||||
SOAP::Lite
|
||||
"
|
||||
|
||||
|
||||
## -
|
||||
## - Install reqired debian packages
|
||||
## -
|
||||
|
||||
declare -a required_debian_packages_arr
|
||||
for _debian_pkg in $_required_debian_packages ; do
|
||||
required_debian_packages_arr+=("$_debian_pkg")
|
||||
done
|
||||
> ${_logdir}/debian-install.log
|
||||
|
||||
echo ""
|
||||
echo -e "\tInstalling required debian packages .."
|
||||
|
||||
for _debian_pkg in ${required_debian_packages_arr[@]} ; do
|
||||
|
||||
echononl "\t Installing $_debian_pkg .."
|
||||
if ! dpkg -l $_debian_pkg 2> /dev/null | grep -e "^ii" > /dev/null 2>&1 ; then
|
||||
apt-get install -q -y $_debian_pkg > ${err_log} 2>&1
|
||||
if [ "$?" = 0 ]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
error "$(cat ${err_log})"
|
||||
|
||||
echononl " continue anyway [yes/no]: "
|
||||
read OK
|
||||
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||
echononl "Wrong entry! - repeat [yes/no]: "
|
||||
read OK
|
||||
done
|
||||
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
|
||||
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
## -
|
||||
## - Install required/optional perl modules
|
||||
## -
|
||||
|
||||
declare -a cpan_modules_arr
|
||||
for _module in $_needed_cpan_modules ; do
|
||||
cpan_modules_arr+=("$_module")
|
||||
done
|
||||
> ${_logdir}/cp_modul-install.log
|
||||
|
||||
echo ""
|
||||
echo -e "\tInstalling cpan modules .."
|
||||
|
||||
for _cpan_module in ${cpan_modules_arr[@]} ; do
|
||||
|
||||
echononl "\t Installing $_cpan_module .."
|
||||
cpanm -q --skip-installed $_module > "${err_log}" 2>&1
|
||||
if [[ "$?" -ne 0 ]] ; then
|
||||
echo_failed
|
||||
error "$(cat "${err_log}")"
|
||||
|
||||
echononl " continue anyway [yes/no]: "
|
||||
read OK
|
||||
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||
echononl "Wrong entry! - repeat [yes/no]: "
|
||||
read OK
|
||||
done
|
||||
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
|
||||
|
||||
else
|
||||
echo_ok
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo ""
|
||||
clean_up 0
|
||||
Reference in New Issue
Block a user