Mini Shell
#!/usr/bin/bash
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT
# Note: Also called from Debian
# Arguments:
# RPM
# $1 == 1 - install package
# $1 == 2 - upgrade package
# DEB
# $1 == configure - RPM post/posttrans
# "lve-utils POST TRANS STARTED"
rhel=$2
solo_marker=$3
container_marker=$4
_clshare=$5
cloudlinux_cron_file=$6
app_detector_cron_ver_file=${7}
crondir_dom_coll_file=${8}
force_collecting_domains_is_done=${9}
force_collecting_domains_cron_file=${10}
_clshare_crons=${11}
cl_venv_path=${12}
app_detector_cron_ver=${13}
# Install crons
echo "$(( RANDOM % 60 )) $(( RANDOM % 24 )) * * * root /usr/bin/flock -n /var/run/cloudlinux_cldetect.cronlock /usr/bin/cldetect --update-license" > "$cloudlinux_cron_file"
echo "$(( RANDOM % 60 )) $(( RANDOM % 24 )) * * * root /usr/bin/flock -n /var/run/cloudlinux_summary.cronlock /usr/sbin/cloudlinux-summary --send --json &> /dev/null" >> "$cloudlinux_cron_file"
echo "$(( RANDOM % 60 )) $(( RANDOM % 24 )) * * * root /usr/bin/flock -n /var/run/cloudlinux_summary_rpm.cronlock /usr/sbin/cloudlinux-summary rpm-packages --send --json &> /dev/null" >> "$cloudlinux_cron_file"
# LU-2603 send statistics on first boot
echo "@reboot root test -f /var/lve/.boot_statistics_sent || { /usr/bin/flock -n /var/run/cloudlinux_summary.cronlock /usr/sbin/cloudlinux-summary --send --json &> /dev/null && touch /var/lve/.boot_statistics_sent; }" >> "$cloudlinux_cron_file"
# Install LU-1751 cloudlinux_domains_collector monthly cron
arch=$(uname -i)
if [[ $arch == x86_64* ]]; then
# all systems except CL6x32
# LU-1903. Part 2. Cron file versioning mechanism
# We are creating cron file only if absent or have old version
CRON_CURRENT_VER="<None>"
if [[ -f $app_detector_cron_ver_file ]]; then
CRON_CURRENT_VER=`cat "$app_detector_cron_ver_file"`
fi
avd_cron_cmd='/usr/bin/cloudlinux_domains_collector | /opt/app-version-detector/app-version-detector-wrapper.sh --send-stats --scan-depth=2'
if [[ ! -f "$crondir_dom_coll_file" || "$CRON_CURRENT_VER" != "$app_detector_cron_ver" ]]; then
# versions differ, update cron
DAY=$[ ( RANDOM % 27 ) + 1 ]
cron_file_content="$(( RANDOM % 60 )) $(( RANDOM % 24 )) $DAY * * root /usr/bin/flock -n /var/run/cloudlinux_domains_collector.cronlock $avd_cron_cmd"
echo "$cron_file_content" > "$crondir_dom_coll_file"
echo "$app_detector_cron_ver" > "$app_detector_cron_ver_file"
fi
if [[ ! -f "$force_collecting_domains_is_done" && ! -f "$force_collecting_domains_cron_file" ]]; then
# run the crontask in the next five days
DAY=$(date -d 'now + '$(( RANDOM % 5 + 1 ))'days' +%d)
cron_file_content="$(( RANDOM % 60 )) $(( RANDOM % 24 )) $DAY * * root /usr/bin/flock -n /var/run/cloudlinux_domains_collector.cronlock $avd_cron_cmd \
&& touch $force_collecting_domains_is_done && rm -f $force_collecting_domains_cron_file"
echo "$cron_file_content" > "$force_collecting_domains_cron_file"
fi
fi
if ! /usr/bin/cldetect --detect-cp | grep 'ISPManager' > /dev/null ; then
if [[ -f $solo_marker || -f $container_marker ]]; then
rm -rf /etc/cron.d/lveutils-panel-cron
else
cp -f /usr/bin/lveutils-panel-cron /etc/cron.d/lveutils-panel-cron
chmod 0644 /etc/cron.d/lveutils-panel-cron
fi
fi
# TODO: remove this when we get monitoring back
if [[ -f $solo_marker || -f $container_marker ]]; then
rm -rf /etc/cron.d/cl_plus
else
ln -sf "$_clshare_crons"/cl_plus /etc/cron.d/cl_plus
fi
if [ -f /proc/lve/list ]; then
/usr/sbin/processpaneluserspackages
fi
if [ -e "/etc/cron.d/lveutils-cpanel-cron" ]; then
rm -f /etc/cron.d/lveutils-cpanel-cron
fi
if [[ ! -f $solo_marker && ! -f $container_marker ]]; then
# Move `fs.proc_super_gid` and `fs.symlinkown_gid` to /etc/sysctl.d/90-cloudlinux.conf from /etc/sysctl.conf
"$cl_venv_path"/bin/cl_sysctl migrate --parameter fs.proc_super_gid
"$cl_venv_path"/bin/cl_sysctl migrate --parameter fs.symlinkown_gid
# set securelinks gid if httpd gid != 48 (default)
/usr/bin/cldetect --set-securelinks-gid > /dev/null
# setup fs.proc_super_gid for few special users
/usr/bin/cldetect --setup-supergids > /dev/null
fi
# run license check on install/update
/usr/bin/cldetect --update-license > /dev/null 2>&1
if [[ ! -f $solo_marker && ! -f $container_marker ]]; then
# start services
/sbin/service lve_namespaces restart > /dev/null 2>&1
/sbin/service lvectl restart > /dev/null 2>&1
fi
# this is not needed on CL Solo, cause option just enables lve patches applying
# for apache/php/mysql
# LU-1654: set cloudlinux=yes parameter in /usr/local/directadmin/custombuild/options.conf
if [[ "DirectAdmin" == "$(/usr/bin/cldetect --detect-cp-nameonly)" ]]; then
if [[ ! -f $solo_marker ]]; then
/usr/local/directadmin/custombuild/build set cloudlinux yes
else
/usr/local/directadmin/custombuild/build set cloudlinux no
fi
fi
# populate cache with current control panel name
/usr/bin/flock -n /var/run/cloudlinux_panel-detect.cronlock /usr/bin/package_reinstaller.py init
# "lve-utils POST TRANS FINISHED"
Zerion Mini Shell 1.0