agent_conf.sh 19 KB

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