Advertisement
Guest User

Untitled

a guest
Mar 4th, 2016
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.52 KB | None | 0 0
  1. #!/bin/bash
  2. # ehcp - Easy Hosting Control Panel install/remove by info@ehcp.net (actually, no remove yet)
  3. # this is a basic shell installer, real installation in install_lib.php, which is called by install_1.php, install_2.php
  4. #
  5. # please contact me if you made any modifications.. or you need help
  6. # msn/email: info@ehcp.net
  7. # skype/yahoo/gtalk: bvidinli
  8. #
  9. # Main Developer: info@ehcp.net
  10. # Marcel <marcelbutucea@gmail.com>
  11. # - added initial support for yum (RedHat/CentOS) (not working now)
  12. # - some code ordering, documentation and cleanup
  13. #
  14. # by earnolmartin@gmail.com : many fixes,
  15. # by own3mall@gmail.com : many fixes,
  16. # (Looking for other volunteer developers.. in future, maybe, we may have some budget... )
  17. # last modified by ehcpdeveloper on 1.11.2014 (d-m-y)
  18.  
  19.  
  20. ehcpversion="0.37.4.b"
  21. emailenable=true # write true/false lowercase for bash..
  22.  
  23. echo
  24. echo
  25. #echo "Please Wait... initializing.a If something is very slow, please report on our site: ehcp.net"
  26. echo
  27. echo
  28. chmod -Rf a+r *
  29.  
  30. for j in "noapt" "unattended" "light" ; # read some install parameters.
  31. do
  32. if [ "$1" == "$j" -o "$2" == "$j" -o "$3" == "$j" ] ; then
  33. eval $j=$j # set parameter noapt to that string... and so for others.
  34. echo "Parameter $j is set:(${!j}) "
  35. fi
  36. done
  37.  
  38. if [ "$1" == "-y" -o "$2" == "-y" -o "$3" == "-y" ] ; then
  39. unattended="unattended"
  40. echo "Unattended Enabled... "
  41. fi
  42.  
  43. ################################################################################################
  44. # Function Definitions #
  45. ################################################################################################
  46.  
  47. # Stub function for apt-get
  48.  
  49. function installaptget () {
  50. echo "now let's try to install apt-get on your system."
  51. echo "Not yet implemented"
  52. }
  53.  
  54.  
  55. function check_programs(){
  56. for i in *.php
  57. do
  58. php -l $i > /dev/null
  59. if [ $? -ne 0 ] ; then
  60. echo "programda hata var: $i"
  61. exit
  62. fi
  63. done
  64.  
  65. }
  66.  
  67. # Stub function fot yum
  68.  
  69. function installyum () {
  70. echo "now let's try to install yum on your system."
  71. echo "Not yet implemented"
  72. }
  73.  
  74. # Initial Welcome Screen
  75.  
  76. function ehcpHeader() {
  77. echo
  78. echo
  79. echo "STAGE 1"
  80. echo "====================================================================="
  81. echo
  82. echo "--------------------EHCP PRE-INSTALLER $ehcpversion -------------------------"
  83. echo "-----Easy Hosting Control Panel for Ubuntu, Debian and alikes--------"
  84. echo "-------------------------www.ehcp.net--------------------------------"
  85. echo "---------------------------------------------------------------------"
  86. echo
  87. echo
  88. echo "Now, ehcp pre-installer begins, a series of operations will be performed and main installer will be invoked. "
  89. echo "if any problem occurs, refer to www.ehcp.net forum section, or contact me, mail/msn: info@ehcp.net"
  90. echo
  91. echo "For automated installs, use $0 unattended (passwords are default in this case)"
  92.  
  93. echo "Please be patient, press enter to continue"
  94. echo
  95. if [ "$unattended" == "" ] ; then
  96. read
  97. fi
  98.  
  99. echo
  100. echo "Note that ehcp can only be installed automatically on Debian based Linux OS'es or Linux'es with apt-get enabled..(Ubuntu, Kubuntu, debian and so on) Do not try to install ehcp with this installer on redhat, centos and non-debian Linux's... To use ehcp on no-debian systems, you need to manually install.. "
  101. echo "this installer is for installing onto a clean, newly installed Ubuntu/Debian. If you install it on existing system, some existing packages will be removed after prompting, if they conflict with packages that are used in ehcp, so, be careful to answer yes/no when using in non-new system"
  102. echo "Actually, I dont like saying like, 'No warranty, I cannot be responsible for any damage.... ', But, this is just a utility.. use at your own."
  103. echo "ehcp also sends some usage data to developer for statistical/improvement purposes"
  104. echo
  105. echo "Outline of install process:"
  106. echo "1- Install php command line version (Preinstaller)"
  107. echo "2- Run install_1.php and install_2.php to install other server related software, such as mysql/mariadb, apache, nginx (Main installer)"
  108. echo
  109. echo "press enter to continue"
  110. echo
  111. if [ "$unattended" == "" ] ; then
  112. read
  113. fi
  114. }
  115.  
  116. # Check for yum
  117.  
  118. function checkyum () {
  119. which yum > /dev/null 2>&1
  120. if [ "$?" == "0" ]; then
  121. echo "yum is available"
  122. return 0
  123. else
  124. # This should never happen
  125. echo "Please install yum"
  126. installyum
  127. fi
  128. }
  129.  
  130. # Check for apt-get
  131.  
  132. function checkAptget(){
  133.  
  134. sayi=`which apt-get | wc -w`
  135. if [ $sayi -eq 0 ] ; then
  136. echo "apt-get is not found. This is a serious problem. Note that ehcp can only be installed on Debian & Ubuntu & other debian/ubuntu based systems. We strongly suggest Ubuntu."
  137. installaptget
  138. fi
  139.  
  140. echo "apt-get seems to be installed on your system."
  141. aptIsInstalled=1
  142.  
  143. sayi=`grep -v "#" /etc/apt/sources.list | wc -l`
  144.  
  145. if [ $sayi -lt 10 ] ; then
  146. echo
  147. echo "WARNING ! Your /etc/apt/sources.list file contains very few sources, This may cause problems installing some packages.. see http://www.ehcp.net/?q=node/389 for an example file"
  148. echo "This may be normal for some versions of debian"
  149. echo "press enter to continue or Ctrl-C to cancel and fix that file"
  150. if [ "$unattended" == "" ] ; then
  151. read
  152. fi
  153. fi
  154.  
  155. }
  156.  
  157.  
  158. # Retrieve statistics
  159. # Marcel: This freezed the installer on one of my Centos Servers (needs more investigating)
  160. # bvidinli:answer: this infomail may be disabled, only for statistical purposes... may hang if for 10 second if user is not connected to internet, or something is wrong with wget or dns resolution...
  161. # no hanging longer than 10 sec should occur... i think.. btw, your code is perfect, Marcel
  162.  
  163. function infoMail(){
  164. if $emailenable ; then
  165. ip=`ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{print $2}' `
  166. wget -q -O /dev/null --timeout=10 http://www.iyibirisi.com/diger/msg.php?msg=$1.$ip > /dev/null 2>&1 &
  167. fi
  168. }
  169.  
  170. # Function to be called when installing packages, by Marcel <marcelbutucea@gmail.com>
  171.  
  172. function installPack(){
  173.  
  174. if [ -n "$noapt" ] ; then # skip install
  175. echo "skipping apt-get install for:$1"
  176. return
  177. fi
  178.  
  179. if [ $distro == "ubuntu" ] || [ $distro == "debian" ];then
  180. # first, try to install without any prompt, then if anything goes wrong, normal install..
  181. apt-get -y --no-remove --allow-unauthenticated install $1
  182. if [ $? -ne 0 ]; then
  183. apt-get --allow-unauthenticated install $1
  184. fi
  185. else
  186. # Yum is nice, you don't get prompted :)
  187. yum -y -t install $1
  188. fi
  189. }
  190.  
  191. function logToFile(){
  192. logfile="ehcp-apt-get-install.log"
  193. echo "$1" >> $logfile
  194. }
  195.  
  196. function aptget_Update(){
  197. if [ -n "$noapt" ] ; then # skip install
  198. echo "skipping apt-get update"
  199. return
  200. fi
  201.  
  202. apt-get update
  203. }
  204.  
  205. function aptgetInstall(){
  206.  
  207. if [ -n "$noapt" ] ; then # skip install
  208. echo "skipping apt-get install for:$1"
  209. return
  210. fi
  211.  
  212. killall update-manager > /dev/null 2>&1
  213. killall update-notifier > /dev/null 2>&1 # these cause other apt-get commands fail because of dpkg lock
  214.  
  215. # first, try to install without any prompt, then if anything goes wrong, normal install..
  216. cmd="apt-get -y --no-remove --allow-unauthenticated install $1"
  217. echo "Running: $cmd"
  218. logToFile "$cmd"
  219. $cmd
  220.  
  221. if [ $? -ne 0 ]; then
  222. cmd="apt-get --allow-unauthenticated install $1"
  223. logToFile "$cmd"
  224. $cmd
  225. fi
  226.  
  227. }
  228.  
  229. function aptgetRemove(){
  230. if [ -n "$noapt" ] ; then # skip uninstall
  231. echo "skipping apt-get remove for:$1"
  232. return
  233. fi
  234.  
  235. # first, try to uninstall without any prompt, then if anything goes wrong, normal uninstall..
  236. cmd="apt-get -y remove $1"
  237. logToFile "$cmd"
  238. $cmd
  239.  
  240. if [ $? -ne 0 ]; then
  241. cmd="apt-get remove $1"
  242. logToFile "$cmd"
  243. $cmd
  244. fi
  245. }
  246.  
  247. # Get distro name , by Marcel <marcelbutucea@gmail.com>, thanks to marcel for fixing whole code syntax
  248. # No longer works in Ubuntu 13.04
  249. # Fixed by Eric Martin <earnolmartin@gmail.com>
  250. function checkDistro() {
  251.  
  252. # Below code doesn't work
  253.  
  254. #cat /etc/*release | grep -i ubuntu &> /dev/null && distro="ubuntu"
  255. #cat /etc/*release | grep -i red &> /dev/null && distro="redhat" # not yet supported
  256. #cat /etc/*release | grep -i centos && distro="centos"
  257. #cat /etc/*release | grep -i debian &> /dev/null && distro="debian"
  258.  
  259. # Get distro properly
  260. if [ -e /etc/issue ]; then
  261. distro=$( cat /etc/issue | awk '{ print $1 }' )
  262. fi
  263.  
  264. if [ -z "$distro" ]; then
  265. if [ -e /etc/os-release ]; then
  266. distro=$( cat os-release | grep -o "^NAME=.*" | grep -o "[^NAME=\"].*[^\"]" )
  267. fi
  268. fi
  269.  
  270. # Assume Ubuntu
  271. if [ -z "$distro" ]; then
  272. distro="ubuntu"
  273. else
  274. # Convert it to lowercase
  275. distro=$( echo $distro | awk '{print tolower($0)}' )
  276. fi
  277.  
  278.  
  279. # Get actual release version information
  280. version=$( cat /etc/issue | awk '{ print $2 }' )
  281. if [ -z "$version" ]; then
  282. version=$( lsb_release -r | awk '{ print $2 }' )
  283. fi
  284.  
  285. # Separate year and version
  286. if [[ "$version" == *.* ]]; then
  287. yrelease=$( echo "$version" | cut -d. -f1 )
  288. mrelease=$( echo "$version" | cut -d. -f2 )
  289. fi
  290.  
  291. # Get 64-bit OS or 32-bit OS [used in vsftpd fix]
  292. if [ $( uname -m ) == 'x86_64' ]; then
  293. OSBits=64
  294. else
  295. OSBits=32
  296. fi
  297.  
  298. # Another way to get the version number
  299. # version=$(lsb_release -r | awk '{ print $2 }')
  300.  
  301. echo "Your distro is $distro runnning version $version"
  302.  
  303. }
  304.  
  305. # Check if the running user is root, if not restart with sudo
  306. function checkUser() {
  307. if [ `whoami` != "root" ];then
  308. echo "you are $who, you have to be root to use ehcp installation program. switching to root mode, please enter password or re-run install.sh as root"
  309. sudo $0 $@ # restart this with superuser-root privileges
  310. exit
  311. fi
  312. }
  313.  
  314. # Function to kill any running ehcp / php daemons
  315. function killallEhcp() {
  316. for i in `ps aux | grep ehcpdaemon.sh | grep -v grep | awk -F " " '{ print $2 }'`;do
  317. kill -9 $i
  318. done
  319.  
  320. for i in `ps aux | grep 'php index.php' | grep -v grep | awk -F " " '{ print $2 }'`;do
  321. kill -9 $i
  322. done
  323. }
  324.  
  325.  
  326. function checkPhp(){
  327. which php
  328. if [ $? -eq 0 ] ; then
  329. echo "php seems installed. This is good.."
  330. else
  331. echo "PHP IS STILL NOT INSTALLED. THIS IS A SERIOUS PROBLEM. MOST PROBABLY, YOU WILL NOT BE ABLE TO CONTINUE. TRY TO INSTLL PHP yourself."
  332. echo "if rest of install is successfull, then, this is a false alarm, just ignore"
  333. fi
  334. }
  335.  
  336. function launchPanel(){
  337. firefox=`which firefox`
  338. if [ -n "$firefox" ] ; then
  339. echo "now, you should be able to navigate to your panel"
  340. echo "panel admin username: admin "
  341. echo "now will try to launch your control panel, if it is on local computer.. "
  342. echo -e "\nwill use firefox as browser...\n\n"
  343. $firefox "http://localhost" &
  344. fi
  345. }
  346.  
  347. # Thanks a lot to earnolmartin@gmail.com for fail2ban integration & vsftpd fixes.
  348.  
  349. function slaveDNSApparmorFix(){ # by earnolmartin@gmail.com
  350. if [ -e /etc/apparmor.d/usr.sbin.named ]; then
  351. echo -e "\nChanging bind apparmor rule to allow master DNS synchronization for slave setups.\n"
  352. sed -i 's#/etc/bind/\*\* r,#/etc/bind/\*\* rw,#g' /etc/apparmor.d/usr.sbin.named
  353. fi
  354. }
  355.  
  356. function libldapFix(){ # by earnolmartin@gmail.com
  357. # install libldap, for vsftpd fix, without prompts
  358. #Remove originally installed libpam-ldap if it exists
  359. origDir=$(pwd)
  360. aptgetRemove libpam-ldap
  361. DEBIAN_FRONTEND=noninteractive apt-get -y install libpam-ldap
  362. cd $patchDir
  363. mkdir lib32gccfix
  364. cd lib32gccfix
  365. # wget -O "ldap_conf.tar.gz" http://dinofly.com/files/linux/ldap_conf_64bit_vsftpd.tar.gz
  366. # tar -zxvf ldap_conf.tar.gz
  367. # cp ldap.conf /etc/
  368. cd $origDir
  369.  
  370. cp etc/ldap.conf ./
  371. cp etc/ldap.conf /etc/
  372. }
  373.  
  374. function fixVSFTPConfig(){ # by earnolmartin@gmail.com
  375. sed -i 's/chroot_local_user=NO/chroot_local_user=YES/g' /etc/vsftpd.conf
  376. allowWriteValue=$( cat /etc/vsftpd.conf | grep -o "allow_writeable_chroot=.*" | grep -o "=.*$" | grep -o "[^=].*" )
  377. if [ -z "$allowWriteValue" ]; then
  378. sh -c "echo 'allow_writeable_chroot=YES' >> /etc/vsftpd.conf"
  379. else
  380. sed -i 's/allow_writeable_chroot=NO/allow_writeable_chroot=YES/g' /etc/vsftpd.conf
  381. fi
  382.  
  383.  
  384. if [ $OSBits -eq "64" ]; then
  385. #aptgetInstall libpam-ldap # this is required in buggy vsftpd installs.. ubuntu 12.04,12.10, 13.04, now...
  386. libldapFix
  387. aptgetInstall libgcc1
  388. # 64-bit 500 OOPS: priv_sock_get_cmd Fix
  389. # seccomp_sandbox=NO
  390. allowSandBox=$( cat /etc/vsftpd.conf | grep -o "seccomp_sandbox=.*" | grep -o "=.*$" | grep -o "[^=].*" )
  391. if [ -z "$allowSandBox" ]; then
  392. if [ "$yrelease" -ge "13" ] ; then
  393. sh -c "echo 'seccomp_sandbox=NO' >> /etc/vsftpd.conf"
  394. fi
  395. else
  396. sed -i 's/seccomp_sandbox=YES/seccomp_sandbox=NO/g' /etc/vsftpd.conf
  397. fi
  398. fi
  399. service vsftpd restart
  400. }
  401.  
  402. function remove_vsftpd(){
  403. #Remove originally installed vsftpd
  404. aptgetRemove vsftpd
  405. # Just incase it's been installed already or another version has been installed using dpgk, let's remove it
  406. dpkg --remove vsftpd
  407. }
  408.  
  409. function fixApacheDefault(){ # by own3mall@gmail.com
  410. ApacheFile="/etc/apache2/apache2.conf"
  411. confStr="IncludeOptional sites-enabled/\*.conf"
  412. correctConfStr="IncludeOptional sites-enabled/\*"
  413. if [ -e "$ApacheFile" ]; then
  414. ConfCheck=$( cat "$ApacheFile" | grep -o "$confStr" )
  415. if [ ! -z "$ConfCheck" ]; then
  416. sed -i "s#$confStr#$correctConfStr#g" "$ApacheFile"
  417. service apache2 restart
  418. fi
  419. fi
  420. }
  421.  
  422. function removeNameVirtualHost(){ # by own3mall@gmail.com
  423. ApacheFile="/etc/apache2/ports.conf"
  424. confStr="NameVirtualHost \*"
  425.  
  426. if [ -e "$ApacheFile" ]; then
  427. ConfCheck=$( cat "$ApacheFile" | grep -o "$confStr" )
  428. if [ ! -z "$ConfCheck" ]; then
  429. sed -i "s#$confStr##g" "$ApacheFile"
  430. service apache2 restart
  431. fi
  432. fi
  433. }
  434.  
  435. function genUbuntuFixes(){ # by own3mall@gmail.com
  436. # Ubuntu packages keep coming with new features that mess things up
  437. # Thanks Ubuntu for the unneccessary headaches!
  438. if [ ! -z "$yrelease" ]; then
  439. if [ "$distro" == "ubuntu" ]; then
  440. if [[ "$yrelease" == "13" && "$mrelease" == "10" ]] || [ "$yrelease" -ge "14" ]; then
  441. fixApacheDefault
  442. removeNameVirtualHost
  443. addConfDFolder
  444. fi
  445. fi
  446. fi
  447. }
  448.  
  449. function addConfDFolder(){
  450. if [ -e "/etc/apache2/apache2.conf" ]; then
  451. APACHECONFCONTENTS=$(cat "/etc/apache2/apache2.conf" | grep "IncludeOptional conf.d")
  452. if [ -z "$APACHECONFCONTENTS" ]; then
  453. echo "IncludeOptional conf.d/*" >> "/etc/apache2/apache2.conf"
  454. fi
  455. fi
  456. }
  457.  
  458. function ubuntuVSFTPDFix(){ # by earnolmartin@gmail.com
  459. # Get currently working directory
  460. origDir=$( pwd )
  461. patchDir="/root/Downloads"
  462. if [ ! -e $patchDir ]; then
  463. mkdir $patchDir
  464. fi
  465. # Ubuntu VSFTPD Fixes
  466. if [ ! -z "$yrelease" ]; then
  467. if [ "$distro" == "ubuntu" ]; then
  468. if [ "$yrelease" == "12" ] ; then
  469. if [ "$mrelease" == "04" ]; then
  470. # Run 12.04 Fix
  471. remove_vsftpd
  472. echo -e "\nRunning VSFTPD fix for Ubuntu 12.04\n"
  473. add-apt-repository -y ppa:thefrontiergroup/vsftpd
  474. aptget_Update
  475. aptgetInstall vsftpd
  476. fixVSFTPConfig
  477.  
  478. elif [ "$mrelease" == "10" ]; then
  479. # Run 12.10 Fix
  480. remove_vsftpd
  481. echo -e "\nRunning VSFTPD fix for Ubuntu 12.10\n"
  482. #get the code
  483. cd $patchDir
  484. if [ ! -e vsftpd_2.3.5-3ubuntu1.deb ]; then
  485. if [ $OSBits -eq "32" ]; then
  486. wget -O "vsftpd_2.3.5-3ubuntu1.deb" http://dinofly.com/files/linux/vsftpd_2.3.5-3ubuntu1_i386.deb
  487. else
  488. wget -O "vsftpd_2.3.5-3ubuntu1.deb" http://dinofly.com/files/linux/vsftpd_2.3.5-3.jme_amd64.deb
  489. fi
  490. fi
  491. #install
  492. dpkg -i vsftpd_2.3.5-3ubuntu1.deb
  493. cd $origDir
  494. fixVSFTPConfig
  495. fi
  496. elif [ "$yrelease" == "13" ]; then
  497. # Ubuntu 13.04
  498. if [ "$mrelease" == "04" ]; then
  499. remove_vsftpd
  500. echo -e "\nRunning VSFTPD fix for Ubuntu 13.04\n"
  501. cd $patchDir
  502. if [ ! -e vsftpd_3.0.2-patched_ubuntu.deb ]; then
  503. if [ $OSBits -eq "32" ]; then
  504. wget -N -O "vsftpd_3.0.2-patched_ubuntu.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-patched_ubuntu_13.04_x86.deb
  505. else
  506. wget -N -O "vsftpd_3.0.2-patched_ubuntu.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-1ubuntu1_amd64_patched.deb
  507. fi
  508. fi
  509. sudo dpkg -i vsftpd_3.0.2-patched_ubuntu.deb
  510. cd $origDir
  511. fixVSFTPConfig
  512. fi
  513.  
  514. # Ubuntu 13.10
  515. if [ "$mrelease" == "10" ]; then
  516. echo -e "\nRunning VSFTPD fix for Ubuntu 13.10\n"
  517. fixVSFTPConfig
  518. fi
  519. elif [ "$yrelease" -ge "14" ]; then
  520. echo -e "\nRunning VSFTPD fix for Ubuntu"
  521. if [ $OSBits -eq "64" ]; then
  522. remove_vsftpd
  523. # file now within ehcp files. We should check&update this when needed..
  524. # I will test normal vsftpd with U14.04, or seek another ftp solution which supports mysql auth.
  525. # wget -N -O "vsftpd_3.0.2-1ubuntu2.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-1ubuntu2_amd64.deb
  526. # if [ $? -ne 0 ] ; then # just retry
  527. # wget -N -O "vsftpd_3.0.2-1ubuntu2.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-1ubuntu2_amd64.deb
  528. # fi
  529. sudo dpkg -i vsftpd_3.0.2-1ubuntu2.deb
  530. fi
  531. fixVSFTPConfig
  532. fi
  533. fi
  534. fi
  535. }
  536.  
  537. function logDirFix(){ # by earnolmartin@gmail.com
  538. chmod 755 log
  539. chmod 744 log/ehcp_failed_authentication.log
  540. chown www-data:www-data log/ehcp_failed_authentication.log
  541. }
  542.  
  543. function fixBINDPerms(){ # by earnolmartin@gmail.com
  544. chmod -R 774 /etc/bind
  545. }
  546.  
  547. function fix_permissions1(){
  548. # sometime, permissions are lost because of cile copying etc.
  549. chmod a+rx install*
  550. chmod a+rx *.sh
  551. chmod a+rx ehcp
  552. find ./ -type d -exec chmod a+rx {} \; # fix directory perms
  553. }
  554.  
  555. function fixEHCPPerms(){ # by earnolmartin@gmail.com
  556. chmod a+rx /var/www/new/ehcp/
  557. chmod -R a+r /var/www/new/ehcp/
  558. find ./ -type d -exec chmod a+rx {} \;
  559. chown -R www-data:www-data /var/www/new/ehcp/webmail
  560. chmod 755 -R /var/www/new/ehcp/webmail
  561. chmod 755 /var/www/new/index.html
  562. }
  563.  
  564. function fixPHPConfig(){ # by earnolmartin@gmail.com
  565. PHPConfFile="/etc/php5/cli/php.ini"
  566. if [ -e $PHPConfFile ]; then
  567. PHPConfCheck=$( cat $PHPConfFile | grep -o ";extension=mysql.so" )
  568. if [ -z "$PHPConfCheck" ]; then
  569. sed -i "s/extension=mysql.so/;extension=mysql.so/g" $PHPConfFile
  570. service apache2 restart
  571. fi
  572. fi
  573. }
  574.  
  575. function fixPHPPerms(){ # by earnolmartin@gmail.com
  576.  
  577. # PHP Runs Under www-data so www-data must own the vhosts directory
  578. # Set correct permissions on vhosts folder
  579. vhostsDir="/var/www/vhosts"
  580. # this is not a good idea, giving all files www-data permission would cause all files webserver writable, which is a high security issue.
  581. #if [ -e $vhostsDir ]; then
  582. # chown -R www-data:www-data $vhostsDir
  583. # chmod g+s -R $vhostsDir
  584. # chmod 774 -R $vhostsDir
  585. #fi
  586.  
  587. # Add vsftpd user as a member of the www-data group so that it may create/delete files
  588. sudo usermod -a -G www-data vsftpd # this is good, because otherwise, vsftpd cannot delete webserver written files.
  589. }
  590.  
  591. function updateBeforeInstall(){ # by earnolmartin@gmail.com
  592. # Update packages before installing to avoid errors
  593. # return # cancelled now, user should do this his/herself. a few reason: may be dangerous, user may choose to do it later, slowing down installation... etc..
  594. # without this function, apt-get installations cannot be done in a new server..
  595.  
  596. if [ -n "$noapt" ] ; then # skip install
  597. echo "skipping apt-get update"
  598. return
  599. fi
  600.  
  601. if [ "$aptIsInstalled" -eq "1" ] ; then
  602. echo "Updating package information and downloading package updates before installation."
  603. apt-key update
  604. apt-get update -y
  605. # apt-get upgrade -y --allow-unauthenticated
  606. else
  607. echo "apt-get seems not installed, so, cannot update apt repository.. press Enter to continue"
  608. read a
  609. fi
  610. }
  611.  
  612. function check_mysql(){
  613. # mysql hangs somehow on some systems. this checks if mysql working, and tries to start it if not.
  614.  
  615. say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
  616. if [ $say -gt 0 ] ; then
  617. echo "Mysql düzgün calısmıyor galiba.. yeniden deniyor."
  618. killall mysqld
  619. killall mysqld
  620. killall mysqld
  621. service mysql start
  622. fi
  623. say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
  624. if [ $say -gt 0 ] ; then
  625. echo "Mysql düzgün calısmıyor galiba.. yeniden deniyor."
  626. killall mysqld
  627. killall mysqld
  628. killall mysqld
  629. service mysql start
  630. fi
  631. say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
  632. if [ $say -gt 0 ] ; then
  633. echo "mysql hala çalışmıyor.. "
  634. ps aux | grep mysq[l] | grep -v grep | awk '{print $2}' | xargs kill -9
  635. ps aux | grep mysq[l] | grep -v grep | awk '{print $2}' | xargs kill -9
  636. service mysql start
  637. fi
  638. say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
  639. if [ $say -gt 0 ] ; then
  640. echo "I am sory that, mysql seems still not working. We/You should fix this... This may be serious. Your panel may not work without mysql."
  641. fi
  642. }
  643.  
  644. #############################################################
  645. # End Functions & Start Install #
  646. #############################################################
  647. checkUser $@
  648. ehcpHeader
  649.  
  650. fix_permissions1
  651.  
  652. dpkg --configure -a # complete any pending operations, to avoid "dpkg interrupted" errors.
  653.  
  654. installdir=$(pwd)
  655. if [ ! -f $installdir/install.sh ] ; then
  656. echo "install.sh is not in install dir. Run install.sh from within ehcp installation dir."
  657. exit 1
  658. fi
  659.  
  660. #echo "`date`: initializing.b" # i added these echo's because on some system, some stages are very slow. i need to investigate that.
  661. #infoMail "ehcp_1_installstarted_ver_$ehcpversion"
  662. #/etc/init.d/apparmor stop & > /dev/null # apparmor causes many problems..
  663. /etc/init.d/apparmor teardown & > /dev/null # apparmor causes many problems..if anybody knows a better solution, let us know.
  664. checkDistro
  665. killallEhcp
  666.  
  667. if [ -z "$distro" ] ; then
  668. echo "Your system type could not be detected or detected to be ($distro), You may not install ehcp automatically on this system, anyway, to continue press enter"
  669. read
  670. fi
  671.  
  672. checkAptget
  673.  
  674. #Update the system before installation
  675. #If your package information is out of date, MySQL and others may fail to install
  676. updateBeforeInstall
  677.  
  678. #----------------------start some install --------------------------------------
  679. #echo "`date`: initializing.g"
  680. mkdir /etc/ehcp
  681. #aptget_Update
  682.  
  683. aptgetInstall python-software-properties # for add-apt-repository
  684.  
  685. # apt-get upgrade # may be cancelled later... this may be dangerous... server owner should do it manually...
  686. # alias ins='apt-get -y install $1'
  687. # sftp://bv@10.0.2.2
  688. aptgetInstall php5
  689. aptgetInstall php5-mysqlnd # why here: If I install php5-mysql after install_1.php started, mysqli_connect functions does not work.
  690. aptgetInstall php5-cli
  691. aptgetInstall sudo
  692. aptgetInstall wget
  693. aptgetInstall aptitude
  694. aptgetInstall apache2-utils # for password protected directories
  695.  
  696. check_programs
  697.  
  698. # This is needed to provide a default answer for configuring certain packages such as mysql and phpmyadmin
  699. if [ ! -z "$unattended" ]; then
  700. aptgetInstall debconf-utils
  701. fi
  702.  
  703.  
  704. #outside_ip=`echo "" > ip ; wget -q -O ip http://ehcp.net/diger/myip.php ; echo ip`
  705. #rm -f ip
  706.  
  707. echo
  708. echo
  709.  
  710. checkPhp
  711. echo
  712. echo
  713. echo
  714. echo "STAGE 2"
  715. echo "====================================================================="
  716. echo "now running install_1.php "
  717. #infoMail ehcp_2_install-starting-install_1.php
  718. php install_1.php $version $distro $noapt $unattended $light
  719. if [ $? -gt 0 ] ; then
  720. echo "install_1.php returned error, check this.. "
  721. exit 1
  722. else
  723. echo "php ended normally"
  724. fi
  725.  
  726. echo
  727. echo
  728. echo "STAGE 3"
  729. echo "====================================================================="
  730. echo "now running install_2.php "
  731. #infoMail ehcp_2_2_install-starting-install_2.php
  732.  
  733. #Send version to avoid installing nginx on Ubuntu 12.10 --- there is a bug and it's not supported
  734. #php install_2.php $noapt || php /etc/ehcp/install_2.php $noapt # start install_2.php if first install is successfull at php level. to prevent many errors.
  735. php install_2.php $version $distro $noapt $unattended $light
  736. if [ $? -gt 0 ] ; then
  737. echo "install_2.php returned error, check this.. "
  738. exit 1
  739. else
  740. echo "php ended normally"
  741. fi
  742.  
  743.  
  744. ########### Append ehcp restart to crontab, because, ehcp daemon dies sometime..
  745. line="1 */6 * * * /etc/init.d/ehcp restart &"
  746. say=`crontab -l | grep "ehcp restart" | wc -l`
  747. if [ $say -eq 0 ] ; then
  748. (crontab -u root -l; echo "$line" ) | crontab -u root -
  749. fi
  750.  
  751. # Post Install Functions by Eric Arnol-Martin
  752.  
  753. mv /var/www/new/ehcp/install_?.php /etc/ehcp/ # move it, to prevent later unauthorized access of installer from web
  754. cd "/var/www/new/ehcp"
  755. # Run VSFTPD Fix depending on version
  756. ubuntuVSFTPDFix
  757. # Run SlaveDNS Fix So that DNS Zones can be transfered
  758. slaveDNSApparmorFix
  759. # Run log chmod fix
  760. logDirFix
  761. # Configure Fail2Ban for EHCP if Fail2Ban is present and configured
  762. # fail2banCheck # done in install*php files.
  763. # Fix EHCP Permissions
  764. fixEHCPPerms
  765. # Fix extra mysql module getting loaded in the PHP config printing warning messages
  766. fixPHPConfig
  767. # Fix /etc/bind directory permissions required for slave dns
  768. fixBINDPerms
  769. # Fix Perms for PHP CHMOD Fix
  770. fixPHPPerms
  771. # Fix generic problems in Ubuntu
  772. genUbuntuFixes
  773.  
  774. check_mysql
  775.  
  776. echo "$PATH" > path # fill this file, so that ehcp can run correctly in crontab or similar
  777.  
  778.  
  779. infoMail "ehcp_8_install-finished-install.sh_ver_$ehcpversion.$outside_ip"
  780. echo "now running ehcp daemon.."
  781. cd /var/log
  782. /etc/init.d/ehcp restart
  783. echo "ehcp run/restart complete.."
  784. sleep 5 # to let ehcp log fill a little
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791. # you may disable following lines, these are for debug/check purposes.
  792. ps aux > debug.txt
  793. echo "============================================" >> debug.txt
  794. tail -100 /var/log/syslog >> debug.txt
  795. tail -100 /var/log/ehcp.log >> debug.txt
  796.  
  797. if $emailenable ; then
  798. cat debug.txt | sendmail -s "ehcp installation debug info" info@ehcp.net > /dev/null 2>&1
  799. fi
  800.  
  801. echo "
  802. A reseller account is setupd inside your ehcp, to support ehcp development, we will use it when we need some hosting, you may delete it if you want.
  803. thank you for trying/using ehcp
  804.  
  805. if your server is behind a router/modem in your network, you need to Open/redirect necessary ports on your modem/router:
  806. these ports need to be opened/redirected :
  807. 20,21,22,25,53,80,110,143 (tcp+udp)
  808.  
  809. ehcp install finished up to now. we are continuing on simplifying the install process.
  810. sory for any inconvenience. you can contact email/msn: info@ehcp.net
  811. you may join us in developing this control panel.
  812.  
  813. You may visit http://www.ehcp.net
  814. You may support by doing php coding, or html design, graphic design...
  815. You may support by donating free dedicated or virtual servers for this project...
  816. CURRENTLY I NEED A DEDICATED SERVER WITH 8 CORE, 8GRAM, 500G hdd at least.
  817.  
  818. ehcp : Finished all operations.. go to your panel at http://yourip/ now..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement