agent_conf.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. #!/bin/bash
  2. #
  3. # OGP - Open Game Panel
  4. # Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team
  5. #
  6. # http://www.opengamepanel.org/
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License
  10. # as published by the Free Software Foundation; either version 2
  11. # of the License, or any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. #
  22. if [ $EUID -ne 0 -a "$(uname -o)" != "Cygwin" ]; then
  23. echo "This script must be run as root" 1>&2
  24. exit 1
  25. fi
  26. usage()
  27. {
  28. cat << EOF
  29. Usage: $0 option
  30. OPTIONS:
  31. -s password Set the password for the agent's user (Linux)
  32. -p password Set the password for cyg_server user (Windows)
  33. EOF
  34. }
  35. while getopts "hs:p:" OPTION
  36. do
  37. case $OPTION in
  38. s)
  39. sudo_password=$OPTARG
  40. ;;
  41. p)
  42. cs_psw=$OPTARG
  43. ;;
  44. ?)
  45. exit
  46. ;;
  47. esac
  48. done
  49. if [ -z $1 ]
  50. then
  51. usage
  52. exit
  53. fi
  54. if [ "$(uname -o)" == "Cygwin" ]; then
  55. if [ -z $cs_psw ]
  56. then
  57. echo "Must use -p argument instead of -s."
  58. exit
  59. fi
  60. else
  61. if [ -z $sudo_password ]
  62. then
  63. echo "Must use -s argument instead of -p."
  64. exit
  65. fi
  66. fi
  67. readonly DEFAULT_PORT=12679
  68. readonly DEFAULT_IP=0.0.0.0
  69. readonly DEFAULT_FTP_PORT=21
  70. readonly DEFAULT_FTP_PASV_RANGE=40000:50000
  71. readonly AGENT_VERSION='v1.4'
  72. failed()
  73. {
  74. echo "ERROR: ${1}"
  75. exit 1
  76. }
  77. agent_home="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  78. cfgfile=${agent_home}/Cfg/Config.pm
  79. prefsfile=${agent_home}/Cfg/Preferences.pm
  80. bashprefsfile=${agent_home}/Cfg/bash_prefs.cfg
  81. overwrite_config=1
  82. if [ -e ${cfgfile} ]; then
  83. while [ 1 ]
  84. do
  85. echo "Overwrite old configuration?"
  86. echo -n "(yes/no) [Default yes]: "
  87. read octmp
  88. if [ "$octmp" == "yes" -o -z "$octmp" ]
  89. then
  90. break
  91. elif [ "$octmp" == "no" ]
  92. then
  93. overwrite_config=0
  94. break
  95. else
  96. echo "You need to type 'yes', 'no' or leave empty for default value [yes]."
  97. fi
  98. done
  99. fi
  100. if [ "X${overwrite_config}" == "X1" ]
  101. then
  102. if [ -z "$sudo_password" ]; then
  103. if [ -f "$cfgfile" ]; then
  104. sudo_password=`awk '/sudo_password/{print $3}' $cfgfile|sed -e "s#\('\)\(.*\)\(',\)#\2#"`
  105. fi
  106. fi
  107. echo "#######################################################################"
  108. echo ""
  109. echo "OGP agent uses basic encryption to prevent unauthorized users from connecting"
  110. echo "Enter a string of alpha-numeric characters for example 'abcd12345'"
  111. echo "**** NOTE - Use the same key in your Open Game Panel webpage config file - they must match *****"
  112. echo ""
  113. while [ -z "${key}" ]
  114. do
  115. echo -n "Set encryption key: "
  116. read key
  117. done
  118. echo
  119. echo "Set the listen port for the agent. The default should be fine for everyone."
  120. echo "However, if you want to change it that can be done here, otherwise just press Enter."
  121. echo -n "Set listen port [Default ${DEFAULT_PORT}]: "
  122. read port
  123. if [ -z "${port}" ]
  124. then
  125. port=$DEFAULT_PORT
  126. fi
  127. echo
  128. echo "Set the listen IP for the agent."
  129. echo "Use ${DEFAULT_IP} to bind on all interfaces."
  130. echo -n "Set listen IP [Default ${DEFAULT_IP}]: "
  131. read ip
  132. if [ -z "${ip}" ]
  133. then
  134. ip=$DEFAULT_IP
  135. fi
  136. while [ 1 ]
  137. do
  138. echo
  139. echo "For some games the OGP panel is using Steam client."
  140. echo "This client has its own license that you need to agree before continuing."
  141. echo "This agreement is available at http://store.steampowered.com/subscriber_agreement/"
  142. echo;
  143. echo "Do you accept the terms of Steam(tm) Subscriber Agreement?"
  144. echo -n "(Accept|Reject): "
  145. read steam_license
  146. if [ "$steam_license" == "Accept" -o "$steam_license" == "Reject" ]
  147. then
  148. break;
  149. fi
  150. echo "You need to type either 'Accept' or 'Reject'."
  151. done
  152. echo "Writing Config file - $cfgfile"
  153. echo "%Cfg::Config = (
  154. logfile => '${agent_home}/ogp_agent.log',
  155. listen_port => '${port}',
  156. listen_ip => '${ip}',
  157. version => '${AGENT_VERSION}',
  158. key => '${key}',
  159. steam_license => '${steam_license}',
  160. sudo_password => '${sudo_password}',
  161. );" > $cfgfile
  162. if [ $? != 0 ]
  163. then
  164. failed "Failed to write config file."
  165. else
  166. chmod 600 ${cfgfile} || failed "Failed to chmod ${cfgfile} to 600."
  167. fi
  168. echo;
  169. while [ 1 ]
  170. do
  171. echo "The agent should be updated when the service is restarted or started?"
  172. echo -n "(yes|no) [Default yes]: "
  173. read auto_update
  174. if [ "${auto_update}" == "yes" -o "${auto_update}" == "no" -o -z "${auto_update}" ]
  175. then
  176. if [ "${auto_update}" == "yes" ]
  177. then
  178. autoUpdate=1
  179. elif [ -z "${auto_update}" ]
  180. then
  181. autoUpdate=1
  182. else
  183. autoUpdate=0
  184. fi
  185. break;
  186. fi
  187. echo "You need to type 'yes', 'no' or leave empty for default value [yes]."
  188. done
  189. echo;
  190. while [ 1 ]
  191. do
  192. echo "The agent should backup the server log files in the game server directory?"
  193. echo -n "(yes|no) [Default yes]: "
  194. read log_local_copy
  195. if [ "${log_local_copy}" == "yes" -o "${log_local_copy}" == "no" -o -z "${log_local_copy}" ]
  196. then
  197. if [ "${log_local_copy}" == "yes" ]
  198. then
  199. logLocalCopy=1
  200. elif [ -z "${log_local_copy}" ]
  201. then
  202. logLocalCopy=1
  203. else
  204. logLocalCopy=0
  205. fi
  206. break;
  207. fi
  208. echo "You need to type 'yes', 'no' or leave empty for default value [yes]."
  209. done
  210. echo;
  211. echo "After how many days should be deleted the old backups of server's logs?"
  212. echo -n "[Default 30]: "
  213. read delete_logs_after
  214. case ${delete_logs_after} in
  215. ''|*[!0-9]*) deleteLogsAfter=30 ;;
  216. *) deleteLogsAfter=${delete_logs_after} ;;
  217. esac
  218. echo;
  219. while [ 1 ]
  220. do
  221. echo "The agent should automatically restart game servers if they crash?"
  222. echo -n "(yes|no) [Default yes]: "
  223. read auto_restart
  224. if [ "${auto_restart}" == "yes" -o "${auto_restart}" == "no" -o -z "${auto_restart}" ]
  225. then
  226. if [ "${auto_restart}" == "yes" ]
  227. then
  228. autoRestart=1
  229. elif [ -z "${auto_restart}" ]
  230. then
  231. autoRestart=1
  232. else
  233. autoRestart=0
  234. fi
  235. break;
  236. fi
  237. echo "You need to type 'yes', 'no' or leave empty for default value [yes]."
  238. done
  239. echo;
  240. while [ 1 ]
  241. do
  242. echo "Should Open Game Panel create and manage FTP accounts?"
  243. echo -n "(yes|no) [Default yes]: "
  244. read manage_ftp
  245. if [ "${manage_ftp}" == "yes" -o "${manage_ftp}" == "no" -o -z "${manage_ftp}" ]
  246. then
  247. if [ "${manage_ftp}" == "yes" ]
  248. then
  249. ogpManagesFTP=1
  250. elif [ -z "${manage_ftp}" ]
  251. then
  252. ogpManagesFTP=1
  253. else
  254. ogpManagesFTP=0
  255. fi
  256. break;
  257. fi
  258. echo "You need to type 'yes', 'no' or leave empty for default value [yes]."
  259. done
  260. echo;
  261. # Only ask these install questions if users want OGP to manage FTP accounts
  262. if [ "$ogpManagesFTP" == "1" ]
  263. then
  264. if [ "$(uname -o)" != "Cygwin" ]; then
  265. while [ 1 ]
  266. do
  267. echo "If you are running ISPConfig 3 in this machine the agent"
  268. echo "can use it to create FTP accounts instead of using Pure-FTPd."
  269. echo "Would you like to configure this agent to use the API of ISPConfig 3?"
  270. echo -n "(yes|no) [Default no]: "
  271. read IspConfig
  272. if [ "${IspConfig}" == "yes" -o "${IspConfig}" == "no" -o -z "${IspConfig}" ]
  273. then
  274. if [ "${IspConfig}" == "yes" ]
  275. then
  276. ftpMethod="IspConfig"
  277. else
  278. IspConfig="no"
  279. fi
  280. break;
  281. fi
  282. echo "You need to type 'yes', 'no' or leave empty for default value [no]."
  283. done
  284. if [ "${IspConfig}" == "yes" ]
  285. then
  286. while [ 1 ]
  287. do
  288. echo "Do you use HTTPS to access to your ISPConfig 3 Panel?"
  289. echo -n "(yes|no) [Default no]: "
  290. read https
  291. if [ "${https}" == "yes" -o "${https}" == "no" -o -z "${https}" ]
  292. then
  293. if [ "${https}" == "yes" ]
  294. then
  295. secure="s"
  296. else
  297. secure=""
  298. fi
  299. break;
  300. fi
  301. echo "You need to type 'yes', 'no' or leave empty for default value [no]."
  302. done
  303. echo -n "What port do you use to connect to your ISPConfig 3 Panel? [Default 8080]: "
  304. read setport
  305. case ${setport} in
  306. ''|*[!0-9]*) port=8080 ;;
  307. *) port=${setport} ;;
  308. esac
  309. echo -n "Enter an user name to sing in remotelly (Remote user): "
  310. read remote_login_username
  311. echo -n "Enter password (Remote user): "
  312. read remote_login_password
  313. echo -e "<?php\n\$username = '${remote_login_username}';" > ${agent_home}/IspConfig/soap_config.php
  314. echo "\$password = '${remote_login_password}';" >> ${agent_home}/IspConfig/soap_config.php
  315. echo "\$soap_location = 'http${secure}://127.0.0.1:${port}/remote/index.php';" >> ${agent_home}/IspConfig/soap_config.php
  316. echo -e "\$soap_uri = 'http${secure}://127.0.0.1:${port}/remote/';\n?>" >> ${agent_home}/IspConfig/soap_config.php
  317. else
  318. while [ 1 ]
  319. do
  320. echo;
  321. echo "If you have installed the Easy Hosting Control Panel (EHCP - www.ehcp.net),"
  322. echo "the agent can use it to create FTP accounts instead of using Pure-FTPd."
  323. echo "Would you like to configure this agent to use the API of EHCP?"
  324. echo -n "(yes|no) [Default no]: "
  325. read ehcp
  326. if [ "${ehcp}" == "yes" -o "${ehcp}" == "no" -o -z "${ehcp}" ]
  327. then
  328. if [ "${ehcp}" == "yes" ]
  329. then
  330. ftpMethod="EHCP"
  331. fi
  332. break;
  333. fi
  334. echo "You need to type 'yes', 'no' or leave empty for default value [no]."
  335. done
  336. if [ "${ehcp}" == "yes" ]
  337. then
  338. echo "Please enter the MySQL database password for the ehcp user"
  339. echo -n "(created during the install of EHCP): "
  340. read ehcpDB
  341. ehcpConf=${agent_home}/EHCP/config.php
  342. sed -i "s/changeme/${ehcpDB}/" $ehcpConf
  343. else
  344. while [ 1 ]
  345. do
  346. echo;
  347. echo "The agent can use ProFTPd to create FTP accounts."
  348. echo "Would you like to configure this agent to use the ProFTPd?"
  349. echo -n "(yes|no) [Default no]: "
  350. read proftpd
  351. if [ "${proftpd}" == "yes" -o "${proftpd}" == "no" -o -z "${proftpd}" ]
  352. then
  353. if [ "${proftpd}" == "yes" ]
  354. then
  355. ftpMethod="proftpd"
  356. fi
  357. break;
  358. fi
  359. echo "You need to type 'yes', 'no' or leave empty for default value [no]."
  360. done
  361. if [ "${proftpd}" == "yes" ]
  362. then
  363. echo "Please enter the path for proFTPd configuration file"
  364. echo -n "[Default /etc/proftpd/proftpd.conf]: "
  365. read proFTPdConfFile
  366. if [ -z $proFTPdConfFile ]
  367. then
  368. proFTPdConfFile="/etc/proftpd/proftpd.conf"
  369. fi
  370. proFTPdConfPath=$(dirname ${proFTPdConfFile})
  371. while [ 1 ]
  372. do
  373. if [ ! -e $proFTPdConfFile ]
  374. then
  375. echo "The file ${proFTPdConfFile} does not exists,"
  376. echo "what you want to do, reenter it or ignore and continue?"
  377. echo "If your answer is 'ignore' is meant that you will install proFTPd later."
  378. echo -n "(reenter|ignore): "
  379. read answer
  380. if [ "${answer}" == "reenter" -o "${answer}" == "ignore" ]
  381. then
  382. if [ "${answer}" == "reenter" ]
  383. then
  384. echo "Reenter proFTPd's configuration file path:"
  385. read proFTPdConfFile
  386. continue
  387. elif [ "${answer}" == "ignore" ]
  388. then
  389. echo "You will need to append this to ${proFTPdConfFile} once you've installed proftpd:"
  390. bold=`tput bold`
  391. normal=`tput sgr0`
  392. echo -e "\n\n${bold}RequireValidShell off\nAuthUserFile ${proFTPdConfPath}/ftpd.passwd\nAuthGroupFile ${proFTPdConfPath}/ftpd.group${normal}\n\n"
  393. break
  394. fi
  395. fi
  396. echo "You need to type 'reenter' or 'ignore'."
  397. else
  398. if egrep -iq "LoadModule\s*mod_auth_file.c" ${proFTPdConfFile}
  399. then
  400. sed -i "s/\s*#\s*LoadModule\s*mod_auth_file.c/LoadModule mod_auth_file.c/g" ${proFTPdConfFile}
  401. else
  402. echo -e "LoadModule mod_auth_file.c" >> ${proFTPdConfFile}
  403. fi
  404. if egrep -iq "^\s*AuthOrder.*" ${proFTPdConfFile}
  405. then
  406. if egrep -iq "^\s*AuthOrder.*mod_auth_file.c" ${proFTPdConfFile}
  407. then
  408. false
  409. else
  410. sed -ri "s/(^\s*AuthOrder.*)/\1 mod_auth_file.c/g" ${proFTPdConfFile}
  411. fi
  412. else
  413. echo -e "AuthOrder mod_auth_file.c" >> ${proFTPdConfFile}
  414. fi
  415. if egrep -iq "RequireValidShell.*" ${proFTPdConfFile}
  416. then
  417. sed -i "s#RequireValidShell.*#RequireValidShell off#g" ${proFTPdConfFile}
  418. else
  419. echo -e "RequireValidShell off" >> ${proFTPdConfFile}
  420. fi
  421. if egrep -iq "AuthUserFile.*" ${proFTPdConfFile}
  422. then
  423. sed -i "s#AuthUserFile.*#AuthUserFile ${proFTPdConfPath}/ftpd.passwd#g" ${proFTPdConfFile}
  424. else
  425. echo -e "AuthUserFile "${proFTPdConfPath}"/ftpd.passwd" >> ${proFTPdConfFile}
  426. fi
  427. if egrep -iq "AuthGroupFile.*" ${proFTPdConfFile}
  428. then
  429. sed -i "s#AuthGroupFile.*#AuthGroupFile ${proFTPdConfPath}/ftpd.group#g" ${proFTPdConfFile}
  430. else
  431. echo -e "AuthGroupFile "${proFTPdConfPath}"/ftpd.group" >> ${proFTPdConfFile}
  432. fi
  433. if [ ! -e "${proFTPdConfPath}/ftpd.group" ]
  434. then
  435. touch ${proFTPdConfPath}/ftpd.group
  436. fi
  437. if [ ! -e "${proFTPdConfPath}/ftpd.passwd" ]
  438. then
  439. touch ${proFTPdConfPath}/ftpd.passwd
  440. fi
  441. ftpd_user=$(grep -oP '^User\s+\K.+' ${proFTPdConfFile})
  442. ftpd_group=$(grep -oP '^Group\s+\K.+' ${proFTPdConfFile})
  443. agent_user=$(grep -oP 'agent_user=\K.+' /etc/init.d/ogp_agent)
  444. if [ ! -z "$ftpd_user" ] && [ ! -z "$ftpd_group" ] && [ ! -z "$agent_user" ]
  445. then
  446. if [ "$(groups $agent_user|grep $ftpd_group)" == "" ]
  447. then
  448. usermod -aG $ftpd_group $agent_user
  449. fi
  450. if [ -e "${proFTPdConfPath}/ftpd.passwd" -a -e "${proFTPdConfPath}/ftpd.group" ]
  451. then
  452. chmod 640 ${proFTPdConfPath}/ftpd.*
  453. chown -f $ftpd_user:$ftpd_group ${proFTPdConfPath}/ftpd.*
  454. fi
  455. fi
  456. break
  457. fi
  458. done
  459. if [ -e "/etc/init.d/proftpd" ]
  460. then
  461. /etc/init.d/proftpd restart
  462. else
  463. echo "If proftpd is running, to apply the changes, you must restart the service."
  464. fi
  465. else
  466. ftpMethod="PureFTPd"
  467. fi
  468. fi
  469. fi
  470. else
  471. if uname -a|grep -q "x86_64"
  472. then
  473. FZ="yes"
  474. else
  475. while [ 1 ]
  476. do
  477. echo;
  478. echo "If you have installed the FileZilla Server,"
  479. echo "the agent can use it to create FTP accounts instead of using Pure-FTPd."
  480. echo "Would you like to configure this agent to use it?"
  481. echo -n "(yes|no) [Default no]: "
  482. read FZ
  483. if [ "${FZ}" == "yes" -o "${FZ}" == "no" -o -z "${FZ}" ]
  484. then
  485. break;
  486. fi
  487. echo "You need to type 'yes', 'no' or leave empty for default value [no].";
  488. done
  489. fi
  490. if [ "${FZ}" == "yes" ]; then
  491. ftpMethod="FZ"
  492. PF=$(cmd /Q /C echo %PROGRAMFILES\(X86\)% | sed 's/\r$//')
  493. if [ "X${PF}" == "X" ];then PF=$(cmd /Q /C echo %PROGRAMFILES% | sed 's/\r$//'); fi
  494. echo;
  495. echo "Please enter the path for FileZilla server executable file"
  496. echo -n "[Default ${PF}\\FileZilla Server\\FileZilla server.exe]: "
  497. read -r FZ_EXE
  498. if [ -z "${FZ_EXE}" ]
  499. then
  500. FZ_EXE="${PF}\\FileZilla Server\\FileZilla server.exe"
  501. fi
  502. echo;
  503. echo "Please enter the path for FileZilla server xml file"
  504. echo -n "[Default ${PF}\\FileZilla Server\\FileZilla Server.xml]: "
  505. read -r FZ_XML
  506. if [ -z "${FZ_XML}" ]
  507. then
  508. FZ_XML="${PF}\\FileZilla Server\\FileZilla server.xml"
  509. fi
  510. FZ_EXE=$(cygpath -u "$FZ_EXE")
  511. FZ_XML=$(cygpath -u "$FZ_XML")
  512. FZconf=${agent_home}/Cfg/FileZilla.pm
  513. echo -e "%Cfg::FileZilla = (\n\tfz_exe => '${FZ_EXE}',\n\tfz_xml => '${FZ_XML}'\n);" > ${FZconf}
  514. if [ $? != 0 ]
  515. then
  516. failed "Failed to write FileZilla configuration file."
  517. fi
  518. if [ ! -z "$cs_psw" ]; then
  519. UD=$(cmd /Q /C echo %USERDOMAIN% | sed 's/\r$//')
  520. net stop "FileZilla Server"
  521. sc config "FileZilla Server" obj= "${UD}\cyg_server" password= "$cs_psw" type= own
  522. net start "FileZilla Server"
  523. fi
  524. else
  525. if uname -a|grep -qv "x86_64"
  526. then
  527. ftpMethod="PureFTPd"
  528. echo;
  529. echo "Set the listen IP for the PureFTPd."
  530. echo "Default is (${DEFAULT_IP}) to bind on all interfaces."
  531. echo -n "Set listen IP [Default ${DEFAULT_IP}]: "
  532. read ftp_ip
  533. if [ -z "${ftp_ip}" ]
  534. then
  535. ftp_ip=$DEFAULT_IP
  536. fi
  537. echo
  538. echo "Set the listen port for PureFTPd. The default should be fine for everyone."
  539. echo "However, if you want to change it that can be done here, otherwise just press Enter."
  540. echo -n "Set listen port [Default ${DEFAULT_FTP_PORT}]: "
  541. read port
  542. if [ -z "${ftp_port}" ]
  543. then
  544. ftp_port=$DEFAULT_FTP_PORT
  545. fi
  546. echo
  547. echo "Passive-mode downloads."
  548. echo "This is especially useful if the server is behind a firewall."
  549. echo -n "Use only ports in the range?(yes|no)[Default no]: "
  550. read passive_ftp
  551. if [ -z "${passive_ftp}" -o "${passive_ftp}" != "yes" ]
  552. then
  553. ftp_pasv_range=""
  554. else
  555. echo "Enter passive ports range separated by colon (<first port>:<last port>)."
  556. echo -n "[Default ${DEFAULT_FTP_PASV_RANGE}]: "
  557. read ftp_pasv_range
  558. if [ -z "${ftp_pasv_range}" ]
  559. then
  560. ftp_pasv_range=$DEFAULT_FTP_PASV_RANGE
  561. fi
  562. fi
  563. fi
  564. fi
  565. fi
  566. fi
  567. if [ "${ftpMethod}" == "PureFTPd" ]
  568. then
  569. run_pureftpd=1
  570. else
  571. run_pureftpd=0
  572. fi
  573. echo "Writing Preferences file - $prefsfile"
  574. prefs="%Cfg::Preferences = (\n"
  575. prefs="${prefs}\tscreen_log_local => '${logLocalCopy}',\n"
  576. prefs="${prefs}\tdelete_logs_after => '${deleteLogsAfter}',\n"
  577. prefs="${prefs}\togp_manages_ftp => '${ogpManagesFTP}',\n"
  578. prefs="${prefs}\tftp_method => '${ftpMethod}',\n"
  579. prefs="${prefs}\togp_autorestart_server => '${autoRestart}',\n"
  580. if [ "X${proftpd}" == "Xyes" ]
  581. then
  582. prefs="${prefs}\tproftpd_conf_path => '${proFTPdConfPath}'\n"
  583. fi
  584. prefs="${prefs});"
  585. echo -e $prefs > $prefsfile
  586. if [ $? != 0 ]
  587. then
  588. failed "Failed to write preferences file."
  589. fi
  590. echo "Writing bash script preferences file - $bashprefsfile"
  591. echo -e "agent_auto_update=${autoUpdate}\nrun_pureftpd=${run_pureftpd}\nftp_port=${ftp_port}\nftp_ip=${ftp_ip}\nftp_pasv_range=${ftp_pasv_range}" > $bashprefsfile
  592. if [ $? != 0 ]
  593. then
  594. failed "Failed to write MISC configuration file used by bash scripts."
  595. fi
  596. fi