fork(1) download
  1. #!/bin/sh
  2. # ISPsystem install.pkg
  3.  
  4. #set -e
  5.  
  6.  
  7. LOG_PIPE=/tmp/log.pipe.$$
  8. mkfifo ${LOG_PIPE}
  9. LOG_FILE=/tmp/log.file.$$
  10.  
  11. tee < ${LOG_PIPE} ${LOG_FILE} &
  12.  
  13. exec > ${LOG_PIPE}
  14. exec 2> ${LOG_PIPE}
  15.  
  16. LogClean() {
  17. rm -f ${LOG_PIPE}
  18. rm -f ${LOG_FILE}
  19. }
  20.  
  21.  
  22. Usage()
  23. {
  24. cat << EOU >&2
  25.  
  26. Usage:
  27. $0 --help Print this help
  28.  
  29. $0 [options] [mgrname]
  30. --osfamily <FAMILY> REDHAT, DEBIAN . Force if can not be detected.
  31. --osversion <VERSION> Version for OS. Example: wheezy for debain, 6 for centos. Force if can not be detected.
  32. --release <type> Installs managers non-interactively with desired release <type>.
  33. --noinstall Not install packages. Just add repository. Also disable mirror detecting.
  34. --ignore-hostname Ignore incorrect hostname.
  35. --silent Do not ask hostname and activation key. Exit on these errors immediatly.
  36. --no-letsencrypt Disable automatic certificate generation
  37. EOU
  38. }
  39.  
  40. GetMgrUrl() {
  41. # ${1} - mgr
  42. if [ -z ${1} ]; then echo "Empty arg 1" ; return 1; fi
  43.  
  44. if [ "#${1}" = "#billmgr" ]; then
  45. ihttpd_port=443
  46. IPADDR=$(/usr/local/mgr5/sbin/ihttpd | awk -F: '$3 == "443" {print $2}')
  47. IPADDR=$(echo ${IPADDR})
  48. fi
  49. if [ -n "${IPADDR}" ]; then
  50. echo "https://${IPADDR}/${1}"
  51. else
  52.  
  53. ihttpd_port=1500
  54.  
  55. IPADDR=$(echo $SSH_CONNECTION | awk '{print $3}')
  56. if [ -z ${IPADDR} ]; then
  57. if [ "${ISPOSTYPE}" = "FREEBSD" ]; then
  58. IPADDR=$(ifconfig | awk '$1 ~ /inet/ && $2 !~ /127.0.0|::1|fe80:/ {print $2}' |cut -d/ -f1 | head -1)
  59. else
  60. IPADDR=$(ip addr show | awk '$1 ~ /inet/ && $2 !~ /127.0.0|::1|fe80:/ {print $2}' |cut -d/ -f1 | head -1)
  61. fi
  62. fi
  63.  
  64. if echo ${IPADDR} | grep -q ':' ; then
  65. SHOWIPADDR="[${IPADDR}]"
  66. else
  67. SHOWIPADDR=${IPADDR}
  68. fi
  69. echo "https://${SHOWIPADDR}:1500/${1}"
  70. fi
  71. }
  72.  
  73. PkgInstalled() {
  74. case ${ISPOSTYPE} in
  75. REDHAT)
  76. rpm -q ${1} >/dev/null 2>&1 ; return $?
  77. ;;
  78. DEBIAN)
  79. dpkg -s ${1} >/dev/null 2>&1 ; return $?
  80. ;;
  81. *)
  82. :
  83. ;;
  84. esac
  85. }
  86.  
  87. PkgAvailable() {
  88. case ${ISPOSTYPE} in
  89. REDHAT)
  90. yum -q -C info ${1} >/dev/null 2>/dev/null
  91. ;;
  92. DEBIAN)
  93. apt-cache -q show ${1} | grep -q "${1}" >/dev/null 2>/dev/null
  94. ;;
  95. *)
  96. ;;
  97. esac
  98. }
  99.  
  100.  
  101. MgrInstalled() {
  102. if [ -z ${1} ]; then echo "Empty arg 1" ; return 1; fi
  103. if [ -z ${2} ]; then echo "Empty arg 2" ; return 1; fi
  104. Info "================================================="
  105. Info "$2 is installed"
  106. local MGRDOMAIN=$(/usr/local/mgr5/sbin/licctl info ${mgr} | awk -F"[: \t]+" '$1 == "JustInstalled" {print $2}')
  107. if [ -n "${MGRDOMAIN}" ] && ! echo "${MGRDOMAIN}" | grep -qE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' ; then
  108. # TEST FUNCTION
  109. Info "Go to the \"https://${MGRDOMAIN}:1500/${mgr}\" to login"
  110. Info "Login: root"
  111. Info "Password: <root password>"
  112. Info ""
  113. echo "If this doesn't work You can use IP instead of domain"
  114. echo "Like: \"$(GetMgrUrl ${mgr})\""
  115. else
  116. Info "Go to the \"$(GetMgrUrl ${mgr})\" to login"
  117. Info "Login: root"
  118. Info "Password: <root password>"
  119. fi
  120. Info "================================================="
  121. }
  122.  
  123. OpenFirewall() {
  124. local port
  125. port=${1}
  126. if which firewall-cmd >/dev/null && service firewalld status >/dev/null ; then
  127. firewall-cmd --zone=public --add-port ${port}/tcp
  128. elif [ -f /sbin/iptables ]; then
  129. iptables -I INPUT -p tcp --dport ${port} -j ACCEPT
  130. fi
  131. }
  132.  
  133. CloseFirewall() {
  134. local port
  135. port=${1}
  136. if which firewall-cmd >/dev/null && service firewalld status >/dev/null ; then
  137. firewall-cmd --zone=public --remove-port ${port}/tcp || :
  138. elif [ -f /sbin/iptables ]; then
  139. iptables -D INPUT -p tcp --dport ${port} -j ACCEPT || :
  140. fi
  141. }
  142.  
  143. LetsEncrypt() {
  144. test -n "${no_letsencrypt}" && return
  145. local MGRDOMAIN=$(/usr/local/mgr5/sbin/licctl info ${mgr} | awk -F"[: \t]+" '$1 == "JustInstalled" {print $2}')
  146. if [ -n "${MGRDOMAIN}" ] && ! echo "${MGRDOMAIN}" | grep -qE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' ; then
  147. if [ -x /usr/local/mgr5/sbin/letsencrypt.sh ]; then
  148. Info "Trying to get and install Let\`s Encrypt certificate"
  149. OpenFirewall 80 || :
  150. /usr/local/mgr5/sbin/letsencrypt.sh ${MGRDOMAIN} || :
  151. CloseFirewall 80 || :
  152. fi
  153. fi
  154. }
  155.  
  156.  
  157. # Disable dialog
  158. DIALOG_BIN=
  159.  
  160. centos_OSVERSIONS="6 7"
  161. debian_OSVERSIONS="wheezy jessie"
  162. ubuntu_OSVERSIONS="trusty xenial"
  163. freebsd_OSVERSIONS="10.0 10.1 10.2 10.3"
  164. export DEBIAN_FRONTEND=noninteractive
  165. export NOTIFY_SERVER=https://n...content-available-to-author-only...m.com/v1
  166.  
  167. CheckRoot() {
  168. if [ $(id -u) -ne 0 ]; then
  169. Error "You must be root user to continue"
  170. exit 1
  171. fi
  172. local RID=$(id -u root 2>/dev/null)
  173. if [ $? -ne 0 ]; then
  174. Error "User root no found. You should create it to continue"
  175. exit 1
  176. fi
  177. if [ $RID -ne 0 ]; then
  178. Error "User root UID not equals 0. User root must have UID 0"
  179. exit 1
  180. fi
  181. }
  182.  
  183. Infon() {
  184. printf "\033[1;32m$@\033[0m"
  185. }
  186.  
  187. Info()
  188. {
  189. Infon "$@\n"
  190. }
  191.  
  192. Warningn() {
  193. printf "\033[1;35m$@\033[0m"
  194. }
  195.  
  196. Warning()
  197. {
  198. Warningn "$@\n"
  199. }
  200.  
  201. Warnn()
  202. {
  203. Warningn "$@"
  204. }
  205.  
  206. Warn()
  207. {
  208. Warnn "$@\n"
  209. }
  210.  
  211. Error()
  212. {
  213. printf "\033[1;31m$@\033[0m\n"
  214. }
  215.  
  216. DetectManager() {
  217. if [ "${MIGRATION}" != "mgr5" ] && [ "${noinstall}" != "true" ] && [ -d /usr/local/ispmgr ]; then
  218. local MGRLIST=$(ls /usr/local/ispmgr/bin/ 2>/dev/null | tr '\n' ' ')
  219. Error "Old managers is installed: ${MGRLIST}"
  220. exit 1
  221. fi
  222. }
  223.  
  224. CheckSELinux() {
  225. local kern=`uname -s`
  226. if [ "$kern" = "Linux" ]; then
  227. if selinuxenabled > /dev/null 2>&1 ; then
  228. # silent install
  229. if [ -n "$release" ] || [ -n "$silent" ]; then
  230. Error "SELinux is enabled, aborting installation."
  231. exit 1
  232. fi
  233. Error "SELinux is enabled on your server. It is strongly recommended to disable SELinux before you proceed."
  234. local uid=`id -u`
  235. # do we have a root privileges ?
  236. if [ "$uid" = "0" ]; then
  237. echo -n "Would you like to disable SELinux right now (yes/no)?"
  238. local ask1
  239. ask1="true"
  240. while [ "$ask1" = "true" ]
  241. do
  242. ask1="false"
  243. read answer
  244. if [ -z "$answer" ] || [ "$answer" = "yes" ]; then
  245. # do disable SELinux
  246. setenforce 0 >/dev/null 2>&1
  247. cp -n /etc/selinux/config /etc/selinux/config.orig >/dev/null 2>&1
  248. echo SELINUX=disabled > /etc/selinux/config
  249. Error "Reboot is requred to complete the configuration of SELinux."
  250. echo -n "Reboot now (yes/no)?"
  251. local ask2
  252. ask2="true"
  253. while [ "$ask2" = "true" ]
  254. do
  255. ask2="false"
  256. read answer
  257. if [ "$answer" = "yes" ]; then
  258. Info "Rebooting now. Please start installation script again once the server reboots."
  259. shutdown -r now
  260. exit 0
  261. elif [ "$answer" = "no" ]; then
  262. Error "It is strongly recommended to reboot server before you proceed the installation"
  263. else
  264. ask2="true"
  265. echo -n "Please type 'yes' or 'no':"
  266. fi
  267. done
  268. elif [ "$answer" != "no" ]; then
  269. ask1="true";
  270. echo -n "Please type 'yes' or 'no':"
  271. fi
  272. done
  273. fi
  274. fi
  275. fi
  276. }
  277.  
  278. DetectFetch()
  279. {
  280. if [ -x /usr/bin/fetch ]; then
  281. fetch="/usr/bin/fetch -o "
  282. elif [ -x /usr/bin/wget ]; then
  283. if [ "$unattended" = "true" ]; then
  284. fetch="/usr/bin/wget -q -O "
  285. else
  286. fetch="/usr/bin/wget -q -O "
  287. fi
  288. elif [ -x /usr/bin/curl ]; then
  289. fetch="/usr/bin/curl -o "
  290. else
  291. Error "ERROR: no fetch program found."
  292. exit 1
  293. fi
  294. }
  295.  
  296. OSDetect() {
  297. test -n "${ISPOSTYPE}" && return 0
  298. ISPOSTYPE=unknown
  299. kern=$(uname -s)
  300. case "${kern}" in
  301. Linux)
  302. if [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
  303. # RH family
  304. export ISPOSTYPE=REDHAT
  305. elif [ -f /etc/debian_version ]; then
  306. # DEB family
  307. export ISPOSTYPE=DEBIAN
  308. fi
  309. ;;
  310. FreeBSD)
  311. # FreeBSD
  312. export ISPOSTYPE=FREEBSD
  313. ;;
  314. esac
  315. if [ "#${ISPOSTYPE}" = "#unknown" ]; then
  316. Error "Unknown os type. Try to use \"--osfamily\" option"
  317. exit 1
  318. fi
  319.  
  320. }
  321.  
  322.  
  323. BadHostname() {
  324. test -z "${1}" && return 1
  325. local HOSTNAME=${1}
  326.  
  327. LENGTH=$(echo ${HOSTNAME} | wc -m)
  328. if [ ${LENGTH} -lt 2 -o ${LENGTH} -gt 50 ]; then
  329. return 1
  330. fi
  331. if ! echo ${HOSTNAME} | grep -q '\.'; then
  332. return 1
  333. fi
  334. if echo ${HOSTNAME} | grep -q '_'; then
  335. return 1
  336. fi
  337. local TOPLEVEL=$(echo ${HOSTNAME} | awk -F. '{print $NF}')
  338. if [ -z "${TOPLEVEL}" ]; then
  339. return 1
  340. fi
  341. if [ -n "$(echo ${TOPLEVEL} | sed -r 's/[a-zA-Z0-9\-]//g')" ]; then
  342. return 1
  343. fi
  344. }
  345.  
  346.  
  347. GetFirstIp() {
  348. if [ -n "$(which ip 2>/dev/null)" ]; then
  349. ip route get 1 | awk '{print $NF;exit}'
  350. fi
  351. }
  352.  
  353.  
  354. SetHostname() {
  355. # 1 - new hostname
  356. # 2 - old hostname
  357. test -z "${1}" && return 1
  358. # test -z "${2}" && return 1
  359. local HOSTNAME=$(echo ${1} | sed 's|\.+$||')
  360. case "${ISPOSTYPE}" in
  361. REDHAT)
  362. hostname ${HOSTNAME} || return 1
  363. sed -i -r "s|^HOSTNAME=|HOSTNAME=${HOSTNAME}|" /etc/sysconfig/network || return 1
  364. if [ -n "${2}" ]; then
  365. sed -i -r "s|${2}|${HOSTNAME}|g" /etc/hosts || return 1
  366. fi
  367. ;;
  368. DEBIAN)
  369. local CUTHOSTNAME=$(echo ${HOSTNAME%\.*})
  370. hostname ${CUTHOSTNAME} || return 1
  371. echo ${CUTHOSTNAME} > /etc/hostname || return 1
  372. if [ -n "${2}" ]; then
  373. sed -i -r "s|${2}|${HOSTNAME}|g" /etc/hosts || return 1
  374. fi
  375. if ! hostname -f >/dev/null 2>&1 ; then
  376. sed -i -r "s|^([0-9\.]+\s+)${HOSTNAME}\s*$|\1${HOSTNAME} ${CUTHOSTNAME}|g" /etc/hosts
  377. fi
  378. if ! hostname -f >/dev/null 2>&1 ; then
  379. echo "$(GetFirstIp) ${HOSTNAME} ${CUTHOSTNAME}" >> /etc/hosts
  380. fi
  381. if ! hostname -f >/dev/null 2>&1 ; then
  382. Error "Can not set hostname"
  383. return 1
  384. fi
  385. ;;
  386. FREEBSD)
  387. hostname ${HOSTNAME} || return 1
  388. cat /etc/rc.conf | sed -r '/^hostname=/d' > /etc/rc.conf.repo
  389. echo "hostname=\"${HOSTNAME}\"" >> /etc/rc.conf.repo
  390. mv /etc/rc.conf.repo /etc/rc.conf
  391. ;;
  392. esac
  393. }
  394.  
  395. CheckHostname() {
  396. if [ "${ISPOSTYPE}" = "DEBIAN" ]; then
  397. local CURHOSTNAME=$(hostname -f ||:)
  398. else
  399. local CURHOSTNAME=$(hostname || :)
  400. fi
  401. local HOSTNAME=${CURHOSTNAME}
  402. if [ "#${silent}" != "#true" ]; then
  403. while ! BadHostname ${HOSTNAME};
  404. do
  405. Error "You have incorrect hostname: ${HOSTNAME}"
  406. read -p "Enter new hostname(or Ctrl+C to exit): " HOSTNAME
  407. echo
  408. done
  409. Info "You have hostname: ${HOSTNAME}"
  410. if [ ! "${CURHOSTNAME}" = "${HOSTNAME}" ]; then
  411. local err_hn=0
  412. SetHostname ${HOSTNAME} ${CURHOSTNAME} || err_hn=1
  413. if [ ${err_hn} -ne 0 ]; then
  414. echo
  415. Error "Can not change hostname. Please change it manually"
  416. exit 1
  417. fi
  418. fi
  419. else
  420. if ! BadHostname ${HOSTNAME}; then
  421. Error "You have incorrect hostname: ${HOSTNAME}"
  422. Error "Please change it manually"
  423. exit 1
  424. fi
  425. fi
  426. }
  427.  
  428.  
  429. OSVersion() {
  430. test -n "${OSVER}" && return 0
  431. OSVER=unknown
  432. case ${ISPOSTYPE} in
  433. REDHAT)
  434. if ! which which >/dev/null 2>/dev/null ; then
  435. yum -y install which
  436. fi
  437. if [ -z "$(which hexdump 2>/dev/null)" ]; then
  438. yum -y install util-linux-ng
  439. fi
  440. OSVER=$(rpm -q --qf "%{version}" -f /etc/redhat-release)
  441. if echo "${OSVER}" | grep -q Server ; then
  442. OSVER=$(echo "${OSVER}" | sed 's/Server//')
  443. fi
  444. OSVER=${OSVER%%\.*}
  445. if ! echo ${centos_OSVERSIONS} | grep -q -w ${OSVER} ; then
  446. unsupported_osver="true"
  447. fi
  448. ;;
  449. DEBIAN)
  450. /usr/bin/apt-get -qy update
  451. if ! which which >/dev/null 2>/dev/null ; then
  452. /usr/bin/apt-get -qy --allow-unauthenticated install which
  453. fi
  454. if [ -z "$(which lsb_release 2>/dev/null)" ]; then
  455. /usr/bin/apt-get -qy --allow-unauthenticated install lsb-release
  456. fi
  457. if [ -z "$(which hexdump 2>/dev/null)" ]; then
  458. /usr/bin/apt-get -qy --allow-unauthenticated install bsdmainutils
  459. fi
  460. if [ -z "$(which logger 2>/dev/null)" ]; then
  461. /usr/bin/apt-get -qy --allow-unauthenticated install bsdutils
  462. fi
  463. if [ -z "$(which free 2>/dev/null)" ]; then
  464. /usr/bin/apt-get -qy --allow-unauthenticated install procps
  465. fi
  466. if [ -x /usr/bin/lsb_release ]; then
  467. OSVER=$(lsb_release -s -c)
  468. fi
  469. if ! echo "${debian_OSVERSIONS} ${ubuntu_OSVERSIONS}" | grep -q -w ${OSVER} ; then
  470. unsupported_osver="true"
  471. fi
  472. if [ "$(lsb_release -s -i)" = "Ubuntu" ]; then
  473. export reponame=ubuntu
  474. else
  475. export reponame=debian
  476. fi
  477. ;;
  478. esac
  479. if [ "#${OSVER}" = "#unknown" ]; then
  480. Error "Unknown os version. Try to use \"--osversion\" option"
  481. exit 1
  482. fi
  483. if [ "#${unsupported_osver}" = "#true" ]; then
  484. Error "Unsupported os version (${OSVER})"
  485. exit 1
  486. fi
  487. }
  488.  
  489. PingTest() {
  490. local ITER=5
  491. ping -q -c ${ITER} -n ${1} 2>&1 | tail -1 | awk -F '/' '{print $5}' | awk -F. '{print $1}'
  492. }
  493.  
  494. GetFastestMirror() {
  495. # Detect fastest mirror. If redhat not needed. If mirror detected not needed
  496.  
  497. # Mirror already set
  498. if [ -n "${MIRROR}" ]; then
  499. return 0
  500. fi
  501.  
  502. # Thist is developer installation
  503. if ! echo "${release}" | grep -qE "^(stable|beta|beta5|stable5|intbeta|intstable|alpha|5\.[0-9]+)$"; then
  504. export MIRROR=intrepo.download.ispsystem.com
  505. return 0
  506. fi
  507.  
  508. # For RH based OS using fastestmirror plugin. And if we do not planning install packages via install.sh
  509. if [ "#${ISPOSTYPE}" = "#REDHAT" ] || [ "${noinstall}" = "true" ] ; then
  510. MIRROR=download.ispsystem.com
  511. return 0
  512. fi
  513.  
  514. Infon "Detecting fastest mirror..."
  515. local PRU
  516. PRU=$(PingTest download.ispsystem.com)
  517. if [ -z "${PRU}" ]; then
  518. PRU=10000
  519. fi
  520. if [ ${PRU} -lt 10 ]; then
  521. export MIRROR=download.ispsystem.com
  522. else
  523. local PCDN
  524. PCDN=$(PingTest cdn.ispsystem.com)
  525. if [ -z "${PCDN}" ]; then
  526. PCDN=10001
  527. fi
  528. if [ ${PRU} -lt ${PCDN} ]; then
  529. export MIRROR=download.ispsystem.com
  530. else
  531. export MIRROR=cdn.ispsystem.com
  532. fi
  533. fi
  534. Info " Using ${MIRROR}"
  535. }
  536.  
  537.  
  538. OsName() {
  539. case ${ISPOSTYPE} in
  540. REDHAT)
  541. echo "$(rpm -qf /etc/redhat-release)"
  542. ;;
  543. DEBIAN)
  544. echo "$(lsb_release -s -i -c -r | xargs echo |sed 's; ;-;g')-$(dpkg --print-architecture)"
  545. ;;
  546. FREEBSD)
  547. echo FreeBSD
  548. ;;
  549. esac
  550. }
  551.  
  552. GetMachineID() {
  553. if [ ! -f /etc/machine-id ]; then
  554. hexdump -n 16 -e '/2 "%x"' /dev/urandom > /etc/machine-id
  555. fi
  556. echo $(cat /etc/machine-id| awk '{print $1}')
  557. }
  558.  
  559. StartInstall() {
  560. HOSTID=$(GetMachineID)
  561. URL="${NOTIFY_SERVER}/startinstall"
  562. wget --tries=3 --connect-timeout=10 --no-check-certificate --post-data="os=$(OsName)&mirror=${MIRROR}&repo=${release}&mgr=${pkgname}&hostid=${HOSTID}" -O - "${URL}" 2>/dev/null || :
  563. }
  564.  
  565. LicInstall() {
  566. HOSTID=$(GetMachineID)
  567. URL="${NOTIFY_SERVER}/licinstall"
  568. licid=$(/usr/local/mgr5/sbin/licctl info /usr/local/mgr5/etc/${mgr}.lic 2>/dev/null| awk '$1 == "ID:" {print $2}' || :)
  569. licexpire=$(/usr/local/mgr5/sbin/licctl info /usr/local/mgr5/etc/${mgr}.lic 2>/dev/null| awk '$1 == "Expire:" {print $2}' || :)
  570. LICPART="&licid=${licid}&licexpire=${licexpire}"
  571. corever=$(/usr/local/mgr5/bin/core core -v 2>/dev/null)
  572. POST_DATA="hostid=${HOSTID}&mgr=${pkgname}&corever=${corever}"
  573. if [ "#${licid}" != "#0" ]; then
  574. POST_DATA="${POST_DATA}${LICPART}"
  575. fi
  576. wget --tries=3 --connect-timeout=10 --no-check-certificate --post-data="${POST_DATA}" -O - "${URL}" 2>/dev/null || :
  577. }
  578.  
  579. CancelInstall() {
  580. HOSTID=$(GetMachineID)
  581. if [ -n "${1}" ]; then
  582. REASON="&reason=${1}"
  583. fi
  584. URL="${NOTIFY_SERVER}/cancelinstall"
  585. wget --tries=3 --connect-timeout=10 --no-check-certificate --post-data="hostid=${HOSTID}&mgr=${pkgname}${REASON}" -O - "${URL}" 2>/dev/null || :
  586. rm -f ${COOKIES_FILE}
  587. LogClean
  588. }
  589.  
  590. FinishInstall() {
  591. HOSTID=$(GetMachineID)
  592. URL="${NOTIFY_SERVER}/finishinstall"
  593. mgrver=$(/usr/local/mgr5/bin/core ${mgr} -v 2>/dev/null)
  594. wget --tries=3 --connect-timeout=10 --no-check-certificate --post-data="hostid=${HOSTID}&mgr=${pkgname}&mgrver=${mgrver}&url=$(GetMgrUrl ${mgr})" -O - "${URL}" 2>/dev/null || :
  595. rm -f ${COOKIES_FILE}
  596. LogClean
  597. }
  598.  
  599. ErrorInstall() {
  600. HOSTID=$(GetMachineID)
  601. URL="${NOTIFY_SERVER}/errorinstall"
  602. if [ -n "${1}" ]; then
  603. err_text="${1}"
  604. else
  605. #Pkglist
  606. err_text="$(cat ${LOG_FILE} | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | hexdump -v -e '/1 "%02x"' | sed 's/\(..\)/%\1/g')"
  607. fi
  608. wget --tries=3 --connect-timeout=10 --no-check-certificate --post-data="hostid=${HOSTID}&mgr=${pkgname}&text=${err_text}" -O - "${URL}" 2>/dev/null || :
  609. LogClean
  610. exit 1
  611. }
  612.  
  613. DetectInstalled() {
  614. # Check if coremanager is installed
  615. if PkgInstalled coremanager || test -f /usr/local/mgr5/etc/core.conf ; then
  616. export core_installed=yes
  617. fi
  618. }
  619.  
  620. GetCurrentRepo() {
  621. case ${ISPOSTYPE} in
  622. REDHAT)
  623. if [ -f /etc/yum.repos.d/ispsystem.repo ]; then
  624. release=$(grep -E '^name=ispsystem-' /etc/yum.repos.d/ispsystem.repo | tail -1|sed -r 's/name=ispsystem-//g')
  625. fi
  626. if [ -z "${release}" ]; then
  627. rm -f /etc/yum.repos.d/ispsystem.repo
  628. else
  629. added_repo=yes
  630. export MIRROR="$(awk -F= '$1 == "baseurl" {print $2}' /etc/yum.repos.d/ispsystem.repo | awk -F/ '{print $3}')"
  631. fi
  632. ;;
  633. DEBIAN)
  634. if [ -f /etc/apt/sources.list.d/ispsystem.list ]; then
  635. release=$(cat /etc/apt/sources.list.d/ispsystem.list | awk '$1 == "deb" && $2 ~ /http|ftp/ {print $3}' | awk -F- '{print $1}')
  636. fi
  637. if [ -z "${release}" ]; then
  638. rm -f /etc/apt/sources.list.d/ispsystem.list
  639. else
  640. added_repo=yes
  641. export MIRROR="$(awk -F/ '{print $3}' /etc/apt/sources.list.d/ispsystem.list)"
  642. fi
  643. ;;
  644. *)
  645. ;;
  646. esac
  647. }
  648.  
  649. CheckRepo() {
  650. # Check unsupported centos repo
  651.  
  652. # skip if silent install
  653. test -n "${silent}" && return 0
  654.  
  655. # skip if debian
  656. [ "${ISPOSTYPE}" = "DEBIAN" ] && return 0
  657. Info "List of enabled repositories:"
  658. yum --noplugins repolist enabled 2>/dev/null | grep -v repolist
  659. echo ""
  660. local arepos=$(yum --noplugins repolist enabled 2>/dev/null | grep -v repolist | sed '1d' | awk '{print $1}' | awk -F/ '{print $1}' | sed 's/^!//')
  661. if [ -n "${arepos}" ] && ! echo "${arepos}" | grep -q '^base$' ;then
  662. Error "Can not be installed without CentOS base repository"
  663. CancelInstall baserepo
  664. exit 1
  665. fi
  666. local repos=$(yum --noplugins repolist enabled 2>/dev/null | grep -v repolist | sed '1d' | awk '{print $1}' | awk -F/ '{print $1}' | grep -vE '^\!*(ispsystem-.*|epel.*|vz-.*|base|extras|updates|cloudlinux-.*)$')
  667. if echo "${repos}" | grep -v remi-safe | grep -qE "(\s|^)remi(-\w+)*(\s|\n|$)" ; then
  668. Error "Can not be installed with remi repo"
  669. CancelInstall remirepo
  670. exit 1
  671. elif [ -n "${repos}" ]; then
  672. Warningn "You have next unsupported repositories: "
  673. echo ${repos}
  674. Warning "This may cause installtion problems."
  675. Warning "Please disable this repositories for correct installation."
  676. Warningn "Are You really want to continue? (y/N) "
  677. read answer
  678. if [ "#${answer}" != "#y" ]; then
  679. CancelInstall unsupportedrepos
  680. exit 1
  681. fi
  682. fi
  683.  
  684. }
  685.  
  686. CheckDF() {
  687. # Check free disk space for centos
  688. # $1 - partition
  689. # $2 - min size
  690.  
  691. # skip if silent install
  692. test -n "${silent}" && return 0
  693. if [ "${ISPOSTYPE}" = "REDHAT" ]; then
  694. local cursize=$(df -P -m ${1} 2>/dev/null | tail -1 | awk '{print $4}')
  695. test -z "${cursize}" && return 0
  696. if [ ${cursize} -lt ${2} ]; then
  697. Error "You have insufficiently disk space to install in directory ${1}: ${cursize} MB"
  698. Error "You need to have at least ${2} MB"
  699. CancelInstall diskspace
  700. exit 1
  701. fi
  702. fi
  703. }
  704.  
  705. CheckMEM() {
  706. # Chech memory size
  707. # skip if silent install
  708. test -n "${silent}" && return 0
  709. local lowmemlimit=256
  710.  
  711. local lowmem=$(free -m | awk -v lml=${lowmemlimit} 'NR==2 && $2 <= lml {print $2}')
  712.  
  713. if [ -n "${lowmem}" ]; then
  714. Error "You have to low memory: ${lowmem}"
  715. Error "You need to have at least 300 Mb"
  716. CancelInstall lowmem
  717. exit 1
  718. fi
  719. }
  720.  
  721. Pkglist() {
  722. echo "" >> ${LOG_FILE}
  723. echo "List of installed packages" >> ${LOG_FILE}
  724. case ${ISPOSTYPE} in
  725. REDHAT)
  726. rpm -qa | sort >> ${LOG_FILE} 2>&1
  727. ;;
  728. DEBIAN)
  729. dpkg -l >> ${LOG_FILE} 2>&1
  730. ;;
  731. esac
  732.  
  733. }
  734.  
  735. CheckConflicts() {
  736. # Check installed packages with same name
  737. # $1 - package
  738.  
  739. local name=${1}
  740. local short_name=${name%%-*}
  741. test -z "${short_name}" && return 0
  742. if [ "${ISPOSTYPE}" = "REDHAT" ]; then
  743. local vpkglist=$(rpm -qa "${short_name}*")
  744. elif [ "${ISPOSTYPE}" = "DEBIAN" ]; then
  745. vpkglist=$(dpkg -l "${short_name}*" 2>/dev/null | awk '$1 !~ /un/ {print $2 "-" $3}' | grep "^${short_name}"| xargs)
  746. fi
  747. local pkglist=""
  748. for pkg in ${vpkglist}; do
  749. if echo "${pkg}" | grep -q "${short_name}-pkg"; then
  750. continue
  751. else
  752. pkglist="${pkglist} ${pkg}"
  753. fi
  754. done
  755. pkglist="$(echo ${pkglist} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'| xargs)"
  756. if [ -n "${pkglist}" ]; then
  757. Error "You have already installed next ${short_name} packages: "
  758. echo "${pkglist}"
  759. Error "If You want to install ${name} You should remove them first"
  760. CancelInstall conflicts
  761. exit 1
  762. fi
  763. }
  764.  
  765. trap ErrorInstall TERM
  766. set -e
  767.  
  768. # Parsing arguments
  769. while true
  770. do
  771. case "${1}" in
  772. -h | --help)
  773. Usage
  774. exit 0
  775. ;;
  776. --mirror)
  777. MIRROR="${2:-.}"
  778. shift 2
  779. if [ ! -n "${MIRROR}" ]; then
  780. Error "Empty mirror"
  781. exit 1
  782. fi
  783. ;;
  784. --release)
  785. release="${2:-.}"
  786. shift 2
  787. ;;
  788. --osfamily)
  789. ISPOSTYPE="${2:-.}"
  790. if ! echo "${ISPOSTYPE}" | grep -qE "^(REDHAT|DEBIAN)$"; then
  791. Error "Incorrect OS"
  792. exit 1
  793. fi
  794. shift 2
  795. ;;
  796. --osversion)
  797. OSVER="${2:-.}"
  798. shift 2
  799. ;;
  800. --noinstall)
  801. noinstall="true"
  802. shift 1
  803. ;;
  804. --silent)
  805. silent="true"
  806. shift 1
  807. ;;
  808. --ignore-hostname)
  809. ignore_hostname="true"
  810. shift 1
  811. ;;
  812. --disable-fail2ban)
  813. disable_fail2ban="true"
  814. shift 1
  815. ;;
  816. --no-letsencrypt)
  817. no_letsencrypt="true"
  818. shift 1
  819. ;;
  820. *)
  821. inpkgname=${1}
  822. break
  823. ;;
  824. esac
  825. done
  826.  
  827. if [ -f /.dockerinit ]; then
  828. export ignore_hostname="true"
  829. fi
  830.  
  831. if [ -n "${release}" ]; then
  832. if [ "#${release}" = "#beta" ]; then
  833. release=beta5
  834. fi
  835. if [ "#${release}" = "#stable" ]; then
  836. release=stable5
  837. fi
  838. fi
  839.  
  840. if [ "#${MIGRATION}" = "#mgr5" ]; then
  841. Info "This is migration from 4th version"
  842. fi
  843.  
  844. OSDetect
  845. OSVersion
  846.  
  847. Infon "Installing on ${ISPOSTYPE} ${OSVER}"
  848. echo ""
  849.  
  850. Info "System memory:"
  851. free -m
  852. echo ""
  853.  
  854. Info "Disk space:"
  855. df -h -P -l -x tmpfs -x devtmpfs
  856. echo ""
  857.  
  858.  
  859. DetectManager
  860. CheckRoot
  861. CheckSELinux
  862. CheckRepo
  863. CheckDF /var/cache/yum/ 300
  864. CheckDF /usr/local 1024
  865. CheckMEM
  866.  
  867. if [ "#${ignore_hostname}" != "#true" ]; then
  868. CheckHostname
  869. else
  870. export IGNORE_HOSTNAME=yes
  871. fi
  872.  
  873. DetectFetch
  874. DetectInstalled
  875.  
  876. if [ -z "${release}" ]; then
  877. GetCurrentRepo
  878. fi
  879. if [ -n "${release}" ] && [ -n "${added_repo}" ]; then
  880. Info "Detected added repository: ${release}"
  881. Info "updating cache"
  882. case ${ISPOSTYPE} in
  883. REDHAT)
  884. yum clean all || :
  885. ;;
  886. DEBIAN)
  887. apt-get -y update
  888. ;;
  889. esac
  890. fi
  891.  
  892. while [ -z "${release}" ]
  893. do
  894. echo "Which version would You like to install ?"
  895. echo "b) beta version - has the latest functionality"
  896. echo "s) stable version - time-proved version"
  897. echo
  898. read -p "Choose repository type to work with: " n
  899. echo
  900. case ${n} in
  901. r|s|2|stable)
  902. release="stable5"
  903. ;;
  904. b|1|beta)
  905. release="beta5"
  906. ;;
  907. a|alpha)
  908. release="alpha"
  909. ;;
  910. m|master)
  911. release="master"
  912. ;;
  913. si)
  914. release="stable-int"
  915. ;;
  916. bi)
  917. release="beta-int"
  918. ;;
  919. ib)
  920. release="intbeta"
  921. ;;
  922. is)
  923. release="intstable"
  924. ;;
  925. i)
  926. read -p "Enter full repository name: " rn
  927. release="${rn}"
  928. ;;
  929. *)
  930. :
  931. ;;
  932. esac
  933. done
  934.  
  935. MirrorlistInstall() {
  936. # $1 - file with repo
  937. # $2 - repo name (epel, beta e.t.c.)
  938. sed -i -r "s|(mirrorlist=http://d...content-available-to-author-only...m.com/repo/centos/${2})/mirrorlist.txt|\1/mirrorlist-install.txt|" /etc/yum.repos.d/${1}.repo
  939. }
  940.  
  941. MirrorlistDefault() {
  942. # $1 - file with repo
  943. # $2 - repo name (epel, beta e.t.c.)
  944. sed -i -r "s|(mirrorlist=http://d...content-available-to-author-only...m.com/repo/centos/${2})/mirrorlist-install.txt|\1/mirrorlist.txt|" /etc/yum.repos.d/${1}.repo
  945. }
  946.  
  947. RemoveCdnRepo() {
  948. case ${ISPOSTYPE} in
  949. REDHAT)
  950. MirrorlistDefault epel epel
  951. MirrorlistDefault ispsystem-base base
  952. MirrorlistDefault ispsystem ${release}
  953. yum -y makecache || yum -y makecache
  954. ;;
  955. DEBIAN)
  956. if echo "${MIRROR}" | grep -q cdn ; then
  957. sed -i -r "s|(http://)cdn.ispsystem.com|\1download.ispsystem.com|g" /etc/apt/sources.list.d/ispsystem.list
  958. sed -i -r "s|(http://)cdn.ispsystem.com|\1download.ispsystem.com|g" /etc/apt/sources.list.d/ispsystem-base.list
  959. apt-get -y update
  960. fi
  961. ;;
  962. esac
  963. }
  964.  
  965. InstallGpgKey() {
  966. # Install gpg key
  967. case ${ISPOSTYPE} in
  968. REDHAT)
  969. if [ ! -s /etc/pki/rpm-gpg/RPM-GPG-KEY-ISPsystem ]; then
  970. Info "Adding ISPsystem gpg key..."
  971. ${fetch} /etc/pki/rpm-gpg/RPM-GPG-KEY-ISPsystem "http://d...content-available-to-author-only...m.com/repo/ispsystem.gpg.key" || return 1
  972. if [ ! -s /etc/pki/rpm-gpg/RPM-GPG-KEY-ISPsystem ]; then
  973. ${fetch} /etc/pki/rpm-gpg/RPM-GPG-KEY-ISPsystem "http://c...content-available-to-author-only...m.com/repo/ispsystem.gpg.key" || return 1
  974. fi
  975. if [ -s /etc/pki/rpm-gpg/RPM-GPG-KEY-ISPsystem ]; then
  976. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ISPsystem || return 1
  977. else
  978. return 1
  979. fi
  980. fi
  981. ;;
  982. DEBIAN)
  983. if ! apt-key list | grep -q 810F8996 ; then
  984. Info "Adding ISPsystem gpg key..."
  985. ${fetch} - http://${MIRROR}/repo/${reponame}/ispsystem.gpg.key | apt-key add - >/dev/null 2>&1
  986. fi
  987. ;;
  988. esac
  989. }
  990.  
  991. CheckRepo() {
  992. # Check if repository added
  993. # $1 - repo name
  994. case ${ISPOSTYPE} in
  995. REDHAT)
  996. yum repolist enabled 2>/dev/null | awk '{print $1}' | grep -q ${1}
  997. ;;
  998. DEBIAN)
  999. apt-cache policy | awk -vrname=${1}/main '$NF == "Packages" && $(NF-2) == rname' | grep -q ${1}
  1000. ;;
  1001. esac
  1002. }
  1003.  
  1004. InstallEpelRepo() {
  1005. # Install epel repo
  1006. # ${1} = true - Use cdn or mirrorlist
  1007. test "${ISPOSTYPE}" = "REDHAT" || return 0
  1008. test -z "${MIRROR}" && GetFastestMirror
  1009. Infon "Checking epel... "
  1010. if [ ! -f /etc/yum.repos.d/epel.repo ] || ! CheckRepo epel ; then
  1011. if rpm -q epel-release >/dev/null ; then
  1012. Warn "Epel repo file broken. Removing epel-release package"
  1013. rpm -e --nodeps epel-release
  1014. else
  1015. Info "Epel repo not exists"
  1016. fi
  1017. rm -f /etc/yum.repos.d/epel.repo
  1018. fi
  1019. if grep -iq cloud /etc/redhat-release ; then
  1020. Info "Importing EPEL key.."
  1021. rpm --import http://m...content-available-to-author-only...x.ru/epel/RPM-GPG-KEY-EPEL-${OSVER} || return 1
  1022. if ! rpm -q epel-release >/dev/null ; then
  1023. Info "Adding repository EPEL.."
  1024. if [ "${OSVER}" = "6" ]; then
  1025. rpm -iU http://d...content-available-to-author-only...m.com/repo/centos/epel/6/x86_64/epel-release-6-8.noarch.rpm || return 1
  1026. elif [ "${OSVER}" = "7" ]; then
  1027. rpm -iU http://d...content-available-to-author-only...m.com/repo/centos/epel/7/x86_64/e/epel-release-7-5.noarch.rpm || return 1
  1028. fi
  1029. fi
  1030. yum -y update mysql-libs || return 1
  1031. else
  1032. if ! rpm -q epel-release >/dev/null ; then
  1033. # epel-release already in extras repository which enabled by default
  1034. Info "Installing epel-release package.."
  1035. yum -y install epel-release || return 1
  1036. else
  1037. Info "Epel package already installed"
  1038. fi
  1039. fi
  1040. if ! grep -qE "mirrorlist=http://d...content-available-to-author-only...m.com/" /etc/yum.repos.d/epel.repo ; then
  1041. sed -i -r '/\[epel\]/,/\[epel/s|^(mirrorlist=).*|\1http://d...content-available-to-author-only...m.com/repo/centos/epel/mirrorlist.txt|' /etc/yum.repos.d/epel.repo
  1042. yum clean all || :
  1043. fi
  1044. # If install with packages use mirrorlist with cdn
  1045. if [ "${1}" = "true" ]; then
  1046. MirrorlistInstall epel epel
  1047. fi
  1048.  
  1049. }
  1050.  
  1051. InstallDebRepo() {
  1052. # Check debian/ubuntu base repo
  1053. return 0 # Function disabled
  1054. test "${ISPOSTYPE}" = "DEBIAN" || return 0
  1055. if ! CheckRepo ${OSVER} ; then
  1056. Warn "Standard ${reponame}-${OSVER} repository does not enabled. Add it to sources.list"
  1057. if [ "${reponame}" = "debian" ]; then
  1058. echo "deb http://f...content-available-to-author-only...n.org/debian ${OSVER} main contrib non-free" >> /etc/apt/sources.list
  1059. echo "deb http://f...content-available-to-author-only...n.org/debian ${OSVER}-updates main contrib non-free" >> /etc/apt/sources.list
  1060. echo "deb http://s...content-available-to-author-only...n.org ${OSVER}/updates main contrib non-free" >> /etc/apt/sources.list
  1061. else
  1062. echo "deb http://a...content-available-to-author-only...u.com/ubuntu ${OSVER} main restricted universe" >> /etc/apt/sources.list
  1063. echo "deb http://a...content-available-to-author-only...u.com/ubuntu ${OSVER}-updates main restricted universe" >> /etc/apt/sources.list
  1064. echo "deb http://s...content-available-to-author-only...u.com/ubuntu ${OSVER}-security main restricted universe multiverse" >> /etc/apt/sources.list
  1065. fi
  1066. apt-get -y update || return 1
  1067. fi
  1068. }
  1069.  
  1070. InstallBaseRepo() {
  1071. # Check and install ispsystem-base repo
  1072. test -z "${MIRROR}" && GetFastestMirror
  1073. InstallGpgKey || return 1
  1074. case ${ISPOSTYPE} in
  1075. REDHAT)
  1076. Infon "Checking ispsystem-base repo... "
  1077. if [ ! -f /etc/yum.repos.d/ispsystem-base.repo ] || ! CheckRepo ispsystem-base ; then
  1078. Warn "Not found"
  1079. Info "Adding repository ISPsystem-base.."
  1080. rm -f /etc/yum.repos.d/ispsystem-base.repo
  1081. ${fetch} /etc/yum.repos.d/ispsystem-base.repo "http://d...content-available-to-author-only...m.com/repo/centos/ispsystem-base.repo" >/dev/null 2>&1 || return 1
  1082. else
  1083. Info "Found"
  1084. fi
  1085. :
  1086. ;;
  1087. DEBIAN)
  1088. Infon "Checking ispsystem-base repo... "
  1089. if ! CheckRepo base-${OSVER} ; then
  1090. Warn "Not found"
  1091. Info "Adding repository ISPsystem-base.."
  1092. rm -f /etc/apt/sources.list.d/ispsystem-base.list
  1093. if echo "${MIRROR}" | grep -q intrepo ; then
  1094. base_mirror=download.ispsystem.com
  1095. else
  1096. base_mirror=${MIRROR}
  1097. fi
  1098. echo "deb http://${base_mirror}/repo/${reponame} base-${OSVER} main" > /etc/apt/sources.list.d/ispsystem-base.list
  1099. else
  1100. Info "Found"
  1101. fi
  1102. ;;
  1103. esac
  1104. }
  1105.  
  1106. InstallRepo() {
  1107. # Install ispsystem main repo
  1108. # ${1} = true - Use cdn or mirrorlist
  1109. test -z "${MIRROR}" && GetFastestMirror
  1110. InstallEpelRepo ${1} || return 1
  1111. InstallBaseRepo ${1} || return 1
  1112. InstallGpgKey || return 1
  1113. case ${ISPOSTYPE} in
  1114. REDHAT)
  1115. Info "Adding repository ISPsystem.."
  1116. rm -f /etc/yum.repos.d/ispsystem.repo
  1117. if echo "${release}" | grep -qE "^(stable|beta|beta5|stable5|intbeta|intstable|alpha|5\.[0-9]+)$"; then
  1118. ${fetch} /etc/yum.repos.d/ispsystem.repo.tmp "http://${MIRROR}/repo/centos/ispsystem5.repo" >/dev/null 2>&1 || return 1
  1119. sed -i -r "s/__VERSION__/${release}/g" /etc/yum.repos.d/ispsystem.repo.tmp && mv /etc/yum.repos.d/ispsystem.repo.tmp /etc/yum.repos.d/ispsystem.repo || exit
  1120. else
  1121. ${fetch} /tmp/ispsystem.repo "http://${MIRROR}/repo/centos/ispsystem-template.repo" >/dev/null 2>&1 || return 1
  1122. sed -i -r "s|TYPE|${release}|g" /tmp/ispsystem.repo
  1123. mv /tmp/ispsystem.repo /etc/yum.repos.d/ispsystem.repo
  1124. fi
  1125. # If install with pacages use mirrorlist with cdn
  1126. if [ "${1}" = "true" ]; then
  1127. if ! echo "${MIRROR}" | grep -q intrepo; then
  1128. MirrorlistInstall ispsystem-base base
  1129. MirrorlistInstall ispsystem ${release}
  1130. fi
  1131. fi
  1132.  
  1133. # Check if release support gpg
  1134. local gpgenable
  1135. case ${release} in
  1136. beta|beta5)
  1137. gpgenable=yes
  1138. ;;
  1139. 5.*)
  1140. if [ ${release#5.} -gt 59 ]; then
  1141. gpgenable=yes
  1142. fi
  1143. ;;
  1144. *)
  1145. ;;
  1146. esac
  1147. if echo "${MIRROR}" | grep -q intrepo ; then
  1148. gpgenable=yes
  1149. fi
  1150.  
  1151. # Enable gpgkey verification
  1152. if [ -n "${gpgenable}" ]; then
  1153. for f in ispsystem ispsystem-base ; do
  1154. fname=/etc/yum.repos.d/${f}.repo
  1155. if grep -q 'gpgkey=$' ${fname} ; then
  1156. sed -i -r "s/(gpgkey=)$/\1file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-ISPsystem/g" ${fname}
  1157. sed -i -r "s/gpgcheck=0/gpgcheck=1/g" ${fname}
  1158. fi
  1159. done
  1160. fi
  1161. yum -y makecache || yum -y makecache || return 1
  1162. ;;
  1163. DEBIAN)
  1164. Info "Adding repository ISPsystem.."
  1165. rm -f /etc/apt/sources.list.d/ispsystem.list
  1166. if echo "${release}" | grep -qE "^(stable|beta|intbeta|intstable|alpha|5\.[0-9]+)$"; then
  1167. if echo "${release}" | grep -qE "5\.[0-9]+"; then
  1168. echo "deb http://${MIRROR}/repo/${reponame} ${release}-${OSVER} main" > /etc/apt/sources.list.d/ispsystem.list
  1169. else
  1170. ${fetch} /etc/apt/sources.list.d/ispsystem.list "http://${MIRROR}/repo/${reponame}/${OSVER}-ispsystem-${release}.list"
  1171. fi
  1172. if echo ${MIRROR} | grep -q cdn ; then
  1173. sed -i -r "s|(http://)download.ispsystem.com|\1cdn.ispsystem.com|g" /etc/apt/sources.list.d/ispsystem.list
  1174. fi
  1175. else
  1176. echo "deb http://${MIRROR}/repo/${reponame} ${release}-${OSVER} main" > /etc/apt/sources.list.d/ispsystem.list
  1177. fi
  1178. apt-get -y update >/dev/null
  1179. ;;
  1180. FREEBSD)
  1181. mkdir -p /usr/local/etc/pkg/repos
  1182. ${fetch} /usr/local/etc/pkg/repos/ispsystem.conf "http://${MIRROR}/repo/freebsd/${release}.conf"
  1183. if echo ${MIRROR} | grep -q cdn ; then
  1184. sed -i"" -r "s|\(http://\)download.ispsystem.com|\1cdn.ispsystem.com|g" /usr/local/etc/pkg/repos/ispsystem.conf
  1185. fi
  1186. pkg update
  1187. ;;
  1188. *)
  1189. Error "Unsupported os family: ${ISPOSTYPE}"
  1190. ;;
  1191. esac
  1192.  
  1193. mkdir -p /usr/local/mgr5/etc
  1194. chmod 750 /usr/local/mgr5/etc
  1195. if echo "${release}" | grep -qE '^5\.[0-9]+'; then
  1196. echo "${release}" > /usr/local/mgr5/etc/repo.version
  1197. elif [ "#${release}" = "#beta5" ]; then
  1198. echo "beta" > /usr/local/mgr5/etc/repo.version
  1199. elif [ "#${release}" = "#stable5" ]; then
  1200. echo "stable" > /usr/local/mgr5/etc/repo.version
  1201. else
  1202. echo "${release}" > /usr/local/mgr5/etc/repo.version
  1203. fi
  1204. }
  1205.  
  1206.  
  1207. PkgInstall() {
  1208. # Install package if error change mirror if possible
  1209. local pi_fail
  1210. pi_fail=1
  1211. while [ "#${pi_fail}" = "#1" ]; do
  1212. pi_fail=0
  1213. case ${ISPOSTYPE} in
  1214. REDHAT)
  1215. yum -y install ${@} || pi_fail=1
  1216. ;;
  1217. DEBIAN)
  1218. apt-get -y update
  1219. apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y -q install ${@} || pi_fail=1
  1220. ;;
  1221. FREEBSD)
  1222. pkg install -r ispsystem-${release} -y ${@} || pi_fail=1
  1223. ;;
  1224. *)
  1225. ;;
  1226. esac
  1227. if [ "#${pi_fail}" = "#0" ]; then
  1228. return 0
  1229. break
  1230. elif echo ${MIRROR} | grep -q cdn ; then
  1231. export MIRROR=download.ispsystem.com
  1232. InstallRepo
  1233. else
  1234. return 1
  1235. break
  1236. fi
  1237. done
  1238. }
  1239.  
  1240. PkgRemove() {
  1241. # Remove package
  1242. case ${ISPOSTYPE} in
  1243. REDHAT)
  1244. yum -y remove ${@}
  1245. ;;
  1246. DEBIAN)
  1247. apt-get -y -q remove ${@}
  1248. ;;
  1249. *)
  1250. return 1
  1251. ;;
  1252. esac
  1253. }
  1254.  
  1255.  
  1256. CoreInstall() {
  1257. PkgInstall coremanager
  1258. }
  1259.  
  1260.  
  1261. Fail2Ban() {
  1262. if PkgAvailable coremanager-pkg-fail2ban ; then
  1263. # Package coremanager-pkg-fail2ban exist in repo (bug #26482)
  1264. PkgInstall coremanager-pkg-fail2ban || :
  1265. elif [ -x /usr/local/mgr5/sbin/fail2ban.sh ]; then
  1266. Info "Instaling fail2ban"
  1267. local failpkgs=fail2ban
  1268. if [ "${ISPOSTYPE}-${OSVER}" = "REDHAT-7" ]; then
  1269. failpkgs="fail2ban-server"
  1270. fi
  1271. PkgInstall ${failpkgs} || :
  1272. /usr/local/mgr5/sbin/fail2ban.sh && Info "fail2ban configured" || :
  1273. fi
  1274. }
  1275.  
  1276.  
  1277. if [ "#${noinstall}" != "#true" ]; then
  1278.  
  1279. # Installing coremanager
  1280.  
  1281. if [ -n "${inpkgname}" ]; then
  1282. inpkgname=$(echo ${inpkgname} | awk '{print tolower($0)}')
  1283. while [ -z "${mgr}" ] && [ -n "${inpkgname}" ]
  1284. do
  1285. case ${inpkgname} in
  1286. billmanager-standard)
  1287. mgr=billmgr
  1288. pkgname=billmanager-standard
  1289. ;;
  1290. billmanager-advanced)
  1291. mgr=billmgr
  1292. pkgname=billmanager-advanced
  1293. ;;
  1294. billmanager-corporate)
  1295. mgr=billmgr
  1296. pkgname=billmanager-corporate
  1297. ;;
  1298. coremanager)
  1299. mgr=core
  1300. pkgname=coremanager
  1301. ;;
  1302. ispmanager-lite-common|ispmanager-lite|ispmanager-pro|ispmanager-business)
  1303. mgr=ispmgr
  1304. # Rename Pro
  1305. if [ "${inpkgname}" = "ispmanager-pro" ]; then
  1306. pkgname=ispmanager-business
  1307. else
  1308. pkgname=${inpkgname}
  1309. fi
  1310. ;;
  1311. vemanager|vmmanager-ovz)
  1312. mgr=vemgr
  1313. pkgname=vmmanager-ovz
  1314. ;;
  1315. vmmanager-basic|vmmanager-kvm)
  1316. mgr=vmmgr
  1317. pkgname=vmmanager-kvm
  1318. ;;
  1319. vmmanager-cloud)
  1320. mgr=vmmgr
  1321. pkgname=${inpkgname}
  1322. ;;
  1323. dcimanager-essential|dcimanager-progressive|dcimanager-enterprise)
  1324. mgr=dcimgr
  1325. pkgname=${inpkgname}
  1326. ;;
  1327. ipmanager|ipmanager-bind|ipmanager-pdns)
  1328. mgr=ipmgr
  1329. pkgname=${inpkgname}
  1330. ;;
  1331. dnsmanager|dnsmanager-bind|dnsmanager-pdns)
  1332. mgr=dnsmgr
  1333. pkgname=${inpkgname}
  1334. ;;
  1335. ispmanager)
  1336. mgr=ispmgr
  1337. ;;
  1338. billmanager)
  1339. mgr=billmgr
  1340. ;;
  1341. vmmanager)
  1342. mgr=vmmgr
  1343. ;;
  1344. dcimanager)
  1345. mgr=dcimgr
  1346. ;;
  1347. *)
  1348. if echo ${inpkgname} | grep -q \-; then
  1349. inpkgname=$(echo ${inpkgname} | cut -d- -f1)
  1350. else
  1351. Error "Incorrect package name"
  1352. exit 1
  1353. fi
  1354. ;;
  1355. esac
  1356. done
  1357. fi
  1358.  
  1359. while [ -z ${mgr} ]
  1360. do
  1361. if [ ${ISPOSTYPE} != "FREEBSD" ]; then
  1362. Info "Which manager would You like to install ?"
  1363. echo "1) ISPmanager"
  1364. echo "2) VMmanager"
  1365. echo "3) DCImanager"
  1366. echo "4) DNSmanager"
  1367. echo "5) IPmanager"
  1368. echo "6) BILLmanager"
  1369. echo
  1370.  
  1371. read -p "Choose manager: " n
  1372. echo
  1373.  
  1374. echo "Chosen: ${n}"
  1375. echo
  1376.  
  1377. case "$n" in
  1378. 1) mgr=ispmgr ;;
  1379. 2) mgr=vmmgr ;;
  1380. 3) mgr=dcimgr ;;
  1381. 4) mgr=dnsmgr ;;
  1382. 5) mgr=ipmgr ;;
  1383. 6) mgr=billmgr ;;
  1384. *) ;;
  1385. esac
  1386. else
  1387. Info "Which manager would You like to install ?"
  1388. echo "1) ISPmanager"
  1389. echo "2) DNSmanager"
  1390. echo "3) IPmanager"
  1391. echo
  1392.  
  1393. read -p "Choose manager: " n
  1394. echo
  1395.  
  1396. case "$n" in
  1397. 1) mgr=ispmgr ;;
  1398. 2) mgr=dnsmgr ;;
  1399. 3) mgr=ipmgr ;;
  1400. *) ;;
  1401. esac
  1402. fi
  1403. done
  1404.  
  1405. licname="${mgr}"
  1406.  
  1407. case "${mgr}" in
  1408. ipmgr)
  1409. while [ -z ${pkgname} ]
  1410. do
  1411. echo "What version do You want to install"
  1412. echo "1) IPmanager with bind (recommended)"
  1413. echo "2) IPmanager with pdns"
  1414. echo
  1415.  
  1416. read -p "Choose version: " n
  1417. echo
  1418.  
  1419. echo "Chosen: ${n}"
  1420. echo
  1421.  
  1422. case "$n" in
  1423. 1) pkgname=ipmanager ;;
  1424. 2) pkgname=ipmanager-pdns ;;
  1425. *) ;;
  1426. esac
  1427. done
  1428. ;;
  1429. dnsmgr)
  1430. while [ -z ${pkgname} ]
  1431. do
  1432. echo "What version do You want to install"
  1433. echo "1) DNSmanager with bind (recommended)"
  1434. echo "2) DNSmanager with pdns"
  1435. echo
  1436.  
  1437. read -p "Choose version: " n
  1438. echo
  1439.  
  1440. echo "Chosen: ${n}"
  1441. echo
  1442.  
  1443. case "$n" in
  1444. 1) pkgname=dnsmanager ;;
  1445. 2) pkgname=dnsmanager-pdns ;;
  1446. *) ;;
  1447. esac
  1448. done
  1449. ;;
  1450. dcimgr)
  1451. while [ -z ${pkgname} ]
  1452. do
  1453. echo "What version do You want to install"
  1454. echo "1) DCImanager"
  1455. echo "2) DCImanager-Enterprise"
  1456. echo
  1457.  
  1458. read -p "Choose version: " n
  1459. echo
  1460.  
  1461. echo "Chosen: ${n}"
  1462. echo
  1463.  
  1464. case "$n" in
  1465. 1) pkgname=dcimanager-progressive ;;
  1466. 2) pkgname=dcimanager-enterprise ;;
  1467. *) ;;
  1468. esac
  1469. done
  1470. ;;
  1471. vemgr)
  1472. pkgname=vmmanager-ovz
  1473. ;;
  1474. vmmgr)
  1475. while [ -z ${pkgname} ]
  1476. do
  1477. echo "What version do You want to install"
  1478. echo "1) VMmanager-KVM"
  1479. echo "2) VMmanager-OVZ"
  1480. echo "3) VMmanager-Cloud"
  1481. echo
  1482.  
  1483. read -p "Choose version: " n
  1484. echo
  1485.  
  1486. echo "Chosen: ${n}"
  1487. echo
  1488.  
  1489. case "$n" in
  1490. 1) pkgname=vmmanager-kvm ;;
  1491. 2)
  1492. pkgname=vmmanager-ovz
  1493. mgr=vemgr
  1494. ;;
  1495. 3) pkgname=vmmanager-cloud ;;
  1496. *) ;;
  1497. esac
  1498. done
  1499. ;;
  1500. ispmgr)
  1501. while [ -z ${pkgname} ]
  1502. do
  1503. echo "What version do You want to install"
  1504. echo "1) ISPmanager-Lite with recommended software"
  1505. echo "2) ISPmanager-Lite minimal version"
  1506. echo "3) ISPmanager-Business"
  1507. echo
  1508. read -p "Choose version: " n
  1509. echo
  1510.  
  1511. echo "Chosen: ${n}"
  1512. echo
  1513.  
  1514. case "$n" in
  1515. 1) pkgname=ispmanager-lite ;;
  1516. 2) pkgname=ispmanager-lite-common ;;
  1517. 3) pkgname=ispmanager-business ;;
  1518. *) ;;
  1519. esac
  1520. done
  1521. ;;
  1522. core)
  1523. pkgname=coremanager
  1524. ;;
  1525. billmgr)
  1526. while [ -z ${pkgname} ]
  1527. do
  1528. echo "What version do You want to install"
  1529. echo "1) BILLmanager"
  1530. echo "2) BILLmanager-Corporate"
  1531. echo
  1532. read -p "Choose version: " n
  1533. echo
  1534.  
  1535. echo "Chosen: ${n}"
  1536. echo
  1537.  
  1538. case "$n" in
  1539. 1) pkgname=billmanager-advanced ;;
  1540. 2) pkgname=billmanager-corporate ;;
  1541. *) ;;
  1542. esac
  1543. done
  1544. ;;
  1545. esac
  1546.  
  1547. case ${pkgname} in
  1548. ispmanager-lite|ispmanager-lite-common)
  1549. if PkgInstalled ispmanager-business ; then
  1550. Error "ISPmanager-Business already installed"
  1551. exit 1
  1552. fi
  1553. ;;
  1554. ispmanager-business)
  1555. if PkgInstalled ispmanager-lite-common; then
  1556. Error "ISPmanager-Lite already installed"
  1557. exit 1
  1558. fi
  1559. ;;
  1560. billmanager-standard)
  1561. if PkgInstalled billmanager-advanced; then
  1562. Error "BILLmanager-Advanced already installed"
  1563. exit 1
  1564. fi
  1565. if PkgInstalled billmanager-corporate; then
  1566. Error "BILLmanager-Corporate already installed"
  1567. exit 1
  1568. fi
  1569. ;;
  1570. billmanager-advanced)
  1571. if PkgInstalled billmanager-standard; then
  1572. Error "BILLmanager-Standard already installed. Run \"/usr/local/mgr5/sbin/billmgr-upgrade.sh advanced\" to upgrade"
  1573. exit 1
  1574. fi
  1575. if PkgInstalled billmanager-corporate; then
  1576. Error "BILLmanager-Corporate already installed"
  1577. exit 1
  1578. fi
  1579. ;;
  1580. billmanager-corporate)
  1581. if PkgInstalled billmanager-advanced; then
  1582. Error "BILLmanager-Advanced already installed. Run \"/usr/local/mgr5/sbin/billmgr-upgrade.sh corporate\" to upgrade"
  1583. exit 1
  1584. fi
  1585. if PkgInstalled billmanager-standard; then
  1586. Error "BILLmanager-Standard already installed. Run \"/usr/local/mgr5/sbin/billmgr-upgrade.sh corporate\" to upgrade"
  1587. exit 1
  1588. fi
  1589. ;;
  1590. *) ;;
  1591. esac
  1592.  
  1593. # CheckConflicts ${pkgname}
  1594.  
  1595. StartInstall
  1596. trap CancelInstall INT
  1597.  
  1598. if [ "#${added_repo}" != "#yes" ]; then
  1599.  
  1600. InstallDebRepo || ErrorInstall
  1601. IR_FAIL=0
  1602. InstallRepo true || IR_FAIL=1
  1603. if [ ${IR_FAIL} -ne 0 ]; then
  1604. Error "Some errors with repository"
  1605. if echo "${MIRROR}" | grep -q "cdn"; then
  1606. Info "Falling back to mirror download.ispsystem.com"
  1607. export MIRROR=download.ispsystem.com
  1608. IR_FAIL=0
  1609. InstallRepo || IR_FAIL=1
  1610. fi
  1611. fi
  1612. if [ ${IR_FAIL} -ne 0 ]; then
  1613. Error "Problems with repository. Please try again in an hour"
  1614. ErrorInstall
  1615. fi
  1616. else
  1617. InstallDebRepo || ErrorInstall
  1618. InstallEpelRepo || ErrorInstall
  1619. InstallBaseRepo || ErrorInstall
  1620. fi
  1621.  
  1622. default_OS_LIST="centos-6 debian-wheezy centos-7 debian-jessie"
  1623. default_ARCH_LIST="i686 x86_64"
  1624.  
  1625. vmmanager_kvm_ARCH_LIST="x86_64"
  1626.  
  1627. vmmanager_cloud_OS_LIST="centos-6 centos-7"
  1628. vmmanager_cloud_ARCH_LIST="x86_64"
  1629.  
  1630. vmmanager_ovz_OS_LIST="centos-6 centos-7 debian-wheezy"
  1631. vmmanager_ovz_ARCH_LIST="x86_64"
  1632.  
  1633. ipmanager_OS_LIST="centos-6 centos-7 debian-wheezy debian-jessie"
  1634. dnsmanager_OS_LIST="centos-6 centos-7 debian-wheezy debian-jessie"
  1635.  
  1636. billmanager_standard_OS_LIST="centos-7 debian-jessie"
  1637. billmanager_standard_ARCH_LIST="x86_64"
  1638.  
  1639. billmanager_standard_OS_LIST_beta="centos-7 debian-jessie"
  1640. billmanager_standard_ARCH_LIST_beta="x86_64"
  1641.  
  1642. billmanager_advanced_OS_LIST="centos-7 debian-jessie"
  1643. billmanager_advanced_ARCH_LIST="x86_64"
  1644.  
  1645. billmanager_corporate_OS_LIST="centos-7 debian-jessie"
  1646. billmanager_corporate_ARCH_LIST_alpha="x86_64"
  1647.  
  1648. dcimanager_essential_OS_LIST="centos-6 debian-wheezy"
  1649. dcimanager_progressive_OS_LIST="centos-6 debian-wheezy"
  1650. dcimanager_enterprise_OS_LIST="centos-6 debian-wheezy"
  1651.  
  1652. ispmanager_lite_common_OS_LIST="centos-6 centos-7 debian-wheezy debian-jessie ubuntu-trusty ubuntu-xenial"
  1653. ispmanager_lite_OS_LIST="${ispmanager_lite_common_OS_LIST}"
  1654.  
  1655. ispmanager_lite_common_OS_LIST_stable="centos-6 centos-7 debian-wheezy debian-jessie ubuntu-trusty ubuntu-xenial"
  1656. ispmanager_lite_OS_LIST_stable="centos-r centos-7 debian-wheezy debian-jessie ubuntu-trusty ubuntu-xenial"
  1657.  
  1658.  
  1659. ispmanager_business_OS_LIST="centos-6 centos-7 debian-wheezy debian-jessie"
  1660. ispmanager_business_common_OS_LIST="${ispmanager_business_OS_LIST}"
  1661.  
  1662. # # If pkg exist in list use them else use default
  1663. # if [ -n "$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_OS_LIST_${release}})" ]; then
  1664. # os_list=$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_OS_LIST_${release}})
  1665. # elif [ -n "$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_OS_LIST})" ]; then
  1666. # os_list=$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_OS_LIST})
  1667. # else
  1668. # os_list="${default_OS_LIST}"
  1669. # fi
  1670. # if [ -n "$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_ARCH_LIST_${release}})" ]; then
  1671. # arch_list=$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_ARCH_LIST_${release}})
  1672. # elif [ -n "$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_ARCH_LIST})" ]; then
  1673. # arch_list=$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_ARCH_LIST})
  1674. # else
  1675. # arch_list="${default_ARCH_LIST}"
  1676. # fi
  1677. os_list=$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_OS_LIST})
  1678. arch_list="${default_ARCH_LIST}"
  1679.  
  1680. MgrExist() {
  1681. Info "package ${pkgname} exists for follow Linux distribution and architectures:"
  1682. Info "Operation systems: ${os_list}"
  1683. if [ -n "$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_OS_LIST_beta})" ]; then
  1684. Info "Operation systems(beta repository): $(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_OS_LIST_beta})"
  1685. fi
  1686. Info "Architectures: ${arch_list}"
  1687. if [ -n "$(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_ARCH_LIST_beta})" ]; then
  1688. Info "Architectures(beta repository): $(eval echo \${$(echo ${pkgname} | sed 's/-/_/g')_ARCH_LIST_beta})"
  1689. fi
  1690. }
  1691.  
  1692. MgrNotExist() {
  1693. cur_arch=$(uname -m)
  1694. if [ "${ISPOSTYPE}" = "REDHAT" ]; then
  1695. cur_os_name="centos"
  1696. else
  1697. cur_os_name=$(lsb_release -s -i | awk '{print tolower($0)}')
  1698. fi
  1699. cur_os_ver=${OSVER}
  1700. cur_os="${cur_os_name}-${cur_os_ver}"
  1701. mgrnotexist() {
  1702. Error "Package ${pkgname} does not support ${cur_os} ( ${cur_arch} )"
  1703. CancelInstall norepo
  1704. MgrExist
  1705. }
  1706. if ! echo "${arch_list}" | grep -q ${cur_arch}; then
  1707. mgrnotexist
  1708. elif ! echo "${os_list}" | grep -q ${cur_os}; then
  1709. mgrnotexist
  1710. fi
  1711. trap - INT TERM EXIT
  1712. exit 1
  1713. }
  1714.  
  1715. PkgAvailable ${pkgname} || MgrNotExist
  1716.  
  1717. if [ "${mgr}" != "core" ]; then
  1718. CoreInstall || ErrorInstall
  1719.  
  1720. # Xmlgen...
  1721. /usr/local/mgr5/sbin/mgrctl exit >/dev/null
  1722.  
  1723. # License
  1724. licfetch_count=0
  1725. export HTTP_PROXY=""
  1726. export http_proxy=""
  1727. while true
  1728. do
  1729. licerror=0
  1730. licfetch_count=$(expr ${licfetch_count} + 1)
  1731. /usr/local/mgr5/sbin/licctl fetch ${mgr} ${ACTIVATION_KEY} >/dev/null 2>&1 || licerror=$?
  1732. if [ ${licerror} -eq 0 ]; then
  1733. # if not error code get info and exit
  1734. LicInstall
  1735. break
  1736. elif [ ${licfetch_count} -lt 3 ]; then
  1737. # if less than 3 attempt
  1738. sleep 2
  1739. elif [ -z "${ACTIVATION_KEY}" ]; then
  1740. if [ "#${mgr}" = "#ispmgr" ]; then
  1741. Warning "Trial license for this IP has expired"
  1742. else
  1743. Warning "Can not fetch free license for this IP. You can try again later"
  1744. fi
  1745. Warning "You have no commercial license for ${pkgname} or it can't be activated automatically"
  1746. if [ "#${silent}" != "#true" ]; then
  1747. printf "Please enter activation key or press Enter to exit: "
  1748. read ACTIVATION_KEY
  1749. export ACTIVATION_KEY
  1750. fi
  1751. if [ -z "${ACTIVATION_KEY}" ]; then
  1752. exit_flag=1
  1753. fi
  1754. else
  1755. Error "Invalid activation key"
  1756. exit_flag=1
  1757. fi
  1758. if [ -n "${exit_flag}" ]; then
  1759. if locale 2>/dev/null | grep LANG | grep -q "ru_RU.UTF-8" ; then
  1760. Info "Документация находится по адресу: http://d...content-available-to-author-only...m.ru/index.php/Схема_лицензирования"
  1761. else
  1762. Info "Documentation can be found at http://d...content-available-to-author-only...m.com/index.php/Software_licensing_policy"
  1763. fi
  1764. CancelInstall nolic
  1765. trap - INT TERM EXIT
  1766. exit 1
  1767. fi
  1768.  
  1769. done
  1770.  
  1771. # Fetching license for repo change
  1772. /usr/local/mgr5/sbin/licctl fetch ${mgr} >/dev/null 2>&1 || :
  1773.  
  1774. if [ -z "${core_installed}" ]; then
  1775. Info "Checking COREmanager downgrade"
  1776. crelease=${release}
  1777. GetCurrentRepo
  1778. if [ "${crelease}" != "${release}" ]; then
  1779. Info "Downgrading COREmanager"
  1780. PkgRemove coremanager
  1781. PkgInstall coremanager
  1782. else
  1783. Info "Not need to downgrade COREmanager"
  1784. fi
  1785. else
  1786. Info "COREmanager installed before this run. Downgrade checking skipped"
  1787. fi
  1788.  
  1789. LetsEncrypt || :
  1790.  
  1791. fi
  1792.  
  1793. PkgInstall ${pkgname} || ErrorInstall
  1794.  
  1795. if [ -z "${disable_fail2ban}" ]; then
  1796. Fail2Ban
  1797. fi
  1798.  
  1799. FinishInstall &
  1800. RemoveCdnRepo # Remove cdn repo or mirrorrlist-install
  1801. MgrInstalled ${mgr} ${pkgname}
  1802. trap - INT TERM EXIT
  1803. else
  1804. InstallRepo
  1805. LogClean
  1806. fi
Runtime error #stdin #stdout 1.52s 42904KB
stdin
Standard input is empty
stdout
Reading package lists...
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/