modconfig 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. #! /bin/sh
  2. #
  3. # modconfig
  4. #
  5. # Copyright (C) 2000, 2001, 2002 Eggheads Development Team
  6. # Written by Fabian Knittel
  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 (at your option) 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. mc_pn=`echo $0 | sed -e 's/^.*\///'`
  22. mc_top_srcdir=
  23. mc_srcdir=
  24. mc_bindir=.
  25. mc_flag_quiet=yes
  26. mc_flag_onlynew=no
  27. # Read options
  28. while true; do
  29. case ${1} in
  30. --top_srcdir=*)
  31. mc_top_srcdir=`echo ${1} | sed -e 's/^--top_srcdir=//'`
  32. ;;
  33. --top_srcdir)
  34. shift
  35. mc_top_srcdir=${1}
  36. ;;
  37. --srcdir=*)
  38. mc_srcdir=`echo ${1} | sed -e 's/^--srcdir=//'`
  39. ;;
  40. --srcdir)
  41. shift
  42. mc_srcdir=${1}
  43. ;;
  44. --bindir=*)
  45. mc_bindir=`echo ${1} | sed -e 's/^--bindir=//'`
  46. ;;
  47. --bindir)
  48. shift
  49. mc_bindir=${1}
  50. ;;
  51. --quiet|-q)
  52. mc_flag_quiet=yes
  53. ;;
  54. --only-new|-n)
  55. mc_flag_onlynew=yes
  56. ;;
  57. --*)
  58. echo "${mc_pn}: warning: unknown option \`${1}'." 2>&1
  59. ;;
  60. *)
  61. # Non-option parameter.
  62. break
  63. ;;
  64. esac
  65. # Break out of loop if there are no more arguments to process.
  66. if shift; then
  67. :
  68. else
  69. break;
  70. fi
  71. done
  72. # Find srcdir and top_srcdir
  73. if test "x${mc_srcdir}" = x; then
  74. if test "x${mc_top_srcdir}" != x; then
  75. mc_srcdir=${mc_top_srcdir}/src
  76. else
  77. echo "${mc_pn}: error: could not find src directory." 2>&1
  78. exit 1
  79. fi
  80. fi
  81. if test "x${mc_top_srcdir}" = x; then
  82. if test "x${mc_srcdir}" != x; then
  83. mc_top_srcdir=${mc_srcdir}/..
  84. else
  85. echo "${mc_pn}: error: could not find top src directory." 2>&1
  86. exit 1
  87. fi
  88. fi
  89. #
  90. # Files
  91. #
  92. # List of all selected modules (including the `.mod' at the end)
  93. mc_fmodules=${mc_bindir}/.modules
  94. # List of all modules we have detected so far.
  95. mc_fknownmods=${mc_bindir}/.known_modules
  96. mc_mod_dir=${mc_srcdir}/mod
  97. mc_mod_bin_dir=${mc_bindir}/src/mod
  98. mc_fMakefile=${mc_mod_bin_dir}/Makefile
  99. mc_fstatic_h=${mc_mod_dir}/static.h
  100. # File descriptor usage:
  101. # 1 Standard output
  102. # 2 Errors
  103. #
  104. # 6 Misc messages and warnings
  105. # 7 Goes to /dev/null
  106. exec 7>/dev/null
  107. if test "${mc_flag_quiet}" = yes; then
  108. exec 6>&7
  109. else
  110. exec 6>&1
  111. fi
  112. # Detect flags needed to achieve 'echo -n' (originally from GNU autoconf) ...
  113. if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  114. # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  115. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null
  116. then
  117. mc_n= mc_c='
  118. ' mc_t=' '
  119. else
  120. mc_n=-n mc_c= mc_t=
  121. fi
  122. else
  123. mc_n= mc_c='\c' mc_t=
  124. fi
  125. # This helps us call ourself.
  126. mc_self_call="$0 --srcdir=${mc_srcdir} --top_srcdir=${mc_topsrcdir}"
  127. # Assign parameters
  128. mc_cmd=$1
  129. if test "x${mc_cmd}" != x; then
  130. shift
  131. mc_paras=$*
  132. fi
  133. case x${mc_cmd} in
  134. xhelp)
  135. #
  136. # Display help
  137. #
  138. cat 1>&6 <<EOF
  139. Usage: ${mc_pn} [OPTIONS] COMMAND
  140. Commands:
  141. add Add a module to the list of active eggdrop modules.
  142. del Remove a module from that list.
  143. clear Clear the list.
  144. static.h Create \`src/mod/static.h'.
  145. Makefile Create \`src/mod/Makefile'.
  146. configure Interactively select modules.
  147. is-configured Exits 0/1 depending on wether modules where
  148. configured or not.
  149. update-depends Check all module dependencies and add modules missing.
  150. help Displays this information.
  151. detect-modules Find all available modules.
  152. modules-still-exist Check wether all known modules still exist.
  153. eggautoconf Recreate the configure scripts in every module dir.
  154. Options:
  155. --top_srcdir=DIR Top directory (At least one of these two
  156. --srcdir=DIR Source directory directories MUST be supplied.)
  157. --bindir=DIR Binary directory
  158. --quiet [-q] Quiet mode. Only show errors.
  159. Options specific to the \`configure' command:
  160. --only-new [-n] Only query new modules.
  161. EOF
  162. ;;
  163. xis-configured)
  164. #
  165. # Determine wether the modules were configured yet.
  166. #
  167. if test -r "${mc_fmodules}"; then
  168. exit 0
  169. else
  170. exit 1
  171. fi
  172. ;;
  173. xmodules-still-exist)
  174. #
  175. # Check wether all known modules still exist.
  176. #
  177. if ${mc_self_call} -q is-configured; then
  178. mc_known_mods=`cat ${mc_fknownmods}`
  179. echo ${mc_n} "checking for removed modules...${mc_c}" 1>&6
  180. # Check wether all known mods still exist
  181. for mc_mod in ${mc_known_mods}; do
  182. echo ${mc_n} ".${mc_c}" >&6
  183. if test ! -d ${mc_mod_dir}/${mc_mod}; then
  184. grep -v "^${mc_mod}$" ${mc_fknownmods} > ${mc_fknownmods}_new
  185. mv ${mc_fknownmods}_new ${mc_fknownmods}
  186. fi
  187. done
  188. echo " done." 1>&6
  189. fi
  190. ;;
  191. xdetect-modules)
  192. #
  193. # Detect modules. Active modules will be added to the `.modules' file. The
  194. # behaviour changes as soon as `.modules' already exists.
  195. #
  196. echo ${mc_n} "detecting modules...${mc_c}" >&6
  197. if ${mc_self_call} -q is-configured; then
  198. mc_mods_configured=yes
  199. mv ${mc_fmodules} ${mc_fmodules}_old
  200. mc_fmodules_old=${mc_fmodules}
  201. mc_fmodules=${mc_fmodules}_old
  202. else
  203. mc_mods_configured=no
  204. mc_fmodules_old=
  205. fi
  206. mc_mods=`echo ${mc_srcdir}/mod/*.mod | sed -e 's/\.mod//g'`
  207. if test "${mc_mods}" = "${mc_srcdir}/mod/*"; then
  208. echo "${mc_pn}: error: no modules detected." >&2
  209. exit 1
  210. fi
  211. # Add them again.
  212. mc_mods=`echo ${mc_mods} | sed -e 's/\.mod//g'`
  213. for mc_mod in ${mc_mods}; do
  214. mc_mod=`echo ${mc_mod} | sed -e 's/.*\///g'`
  215. mc_new_mod_state=disabled
  216. echo ${mc_n} ".${mc_c}" >&6
  217. # Do we have an existing configuration?
  218. if (test "${mc_mods_configured}" = yes); then
  219. # Is the module active?
  220. if (grep "^${mc_mod}\.mod\$" ${mc_fmodules} 1>&7 2>&1)
  221. then
  222. mc_new_mod_state=enabled
  223. else
  224. # Was it configured before?
  225. if (grep "^${mc_mod}\.mod\$" ${mc_fknownmods} 1>&7 2>&1); then
  226. :
  227. else
  228. mc_new_mod_state=enabled
  229. fi
  230. fi
  231. else
  232. mc_new_mod_state=enabled
  233. fi
  234. if test "${mc_new_mod_state}" = enabled; then
  235. ${mc_self_call} -q add ${mc_mod}
  236. else
  237. ${mc_self_call} -q del ${mc_mod}
  238. fi
  239. done
  240. if test "x${mc_fmodules_old}" != x; then
  241. # mc_fmodules actually points to the .modules_old file.
  242. rm -f ${mc_fmodules}
  243. touch ${mc_fmodules_old}
  244. fi
  245. echo " done." >&6
  246. ;;
  247. xMakefile)
  248. #
  249. # Build `src/mod/Makefile'
  250. #
  251. echo ${mc_n} "building ${mc_fMakefile}... ${mc_c}" 1>&6
  252. # Check for selected modules
  253. if test -r ${mc_fmodules}; then
  254. # Convert newlines to spaces.
  255. mc_sel_modules=`cat ${mc_fmodules} | \
  256. awk '{ printf("%s ", $0); }'`
  257. else
  258. echo "${mc_pn}: error: no modules selected. You did not run \`make config' yet." 1>&2;
  259. exit 1
  260. fi
  261. mc_mod_objs=`echo ${mc_sel_modules} | sed -e 's/\.mod/.mod_o/g'`
  262. if test ! -f ${mc_fMakefile}; then
  263. echo "failed." 1>&6
  264. echo "${mc_pn}: error: make file template not found." 1>&2
  265. exit 1
  266. fi
  267. # The following sed expression modifies src/mod/Makefile to
  268. # hold the new module names.
  269. if (cat "${mc_fMakefile}" | \
  270. sed -e "s/^\(mods =\).*$/\1 ${mc_sel_modules}/g" \
  271. -e "s/^\(mod_objs =\).*$/\1 ${mc_mod_objs}/g" \
  272. 1> "${mc_fMakefile}_new"); then
  273. mv "${mc_fMakefile}_new" "${mc_fMakefile}"
  274. else
  275. echo "failed." 1>&6
  276. echo "${mc_pn}: sed failed to build ${mc_fMakefile}." 1>&2
  277. exit 1
  278. fi
  279. echo "done." 1>&6
  280. ;;
  281. xstatic.h)
  282. #
  283. # Build `static.h'
  284. #
  285. echo ${mc_n} "building static.h..." 1>&6
  286. # Check for selected modules
  287. if test ! -r ${mc_fmodules}; then
  288. echo " failed." 1>&6
  289. echo "${mc_pn}: error: no modules selected. You did not run \`make config' yet." 1>&2;
  290. exit 1
  291. fi
  292. mc_sel_modules=`cat ${mc_fmodules} | sed -e 's/\.mod//g'`
  293. # Note: All data is written to `src/mod/static.h' which is
  294. # later included into `src/main.c'.
  295. # Remove old static.h
  296. rm -f ${mc_fstatic_h}
  297. # Header
  298. cat 1>> ${mc_fstatic_h} << EOF
  299. /* src/mod/static.h -- header file for static compiles.
  300. *
  301. * NOTE: Do not edit directly. Instead, re-run \`make config'.
  302. */
  303. #ifndef _EGG_MOD_STATIC_H
  304. #define _EGG_MOD_STATIC_H
  305. EOF
  306. # Create declarations for module _start functions
  307. for mc_mod in ${mc_sel_modules}; do
  308. echo ${mc_n} ".${mc_c}" 1>&6
  309. if test ${mc_mod} = "server" || test ${mc_mod} = "irc";then echo "#ifdef LEAF" 1>> ${mc_fstatic_h};fi
  310. echo "char *${mc_mod}_start();" 1>> ${mc_fstatic_h}
  311. if test ${mc_mod} = "server" || test ${mc_mod} = "irc";then echo "#endif" 1>> ${mc_fstatic_h};fi
  312. done
  313. echo 1>> ${mc_fstatic_h}
  314. # The link_statics() function ...
  315. echo "static void link_statics()" 1>> ${mc_fstatic_h}
  316. echo "{" 1>> ${mc_fstatic_h}
  317. for mc_mod in ${mc_sel_modules}; do
  318. if test ${mc_mod} = "server" || test ${mc_mod} = "irc";then echo "#ifdef LEAF" 1>> ${mc_fstatic_h};fi
  319. echo " check_static(\"${mc_mod}\", ${mc_mod}_start);" 1>> ${mc_fstatic_h}
  320. if test ${mc_mod} = "server" || test ${mc_mod} = "irc";then echo "#endif" 1>> ${mc_fstatic_h};fi
  321. done
  322. cat 1>> ${mc_fstatic_h} << EOF
  323. }
  324. #endif /* _EGG_MOD_STATIC_H */
  325. EOF
  326. echo " done." 1>&6
  327. ;;
  328. xdel)
  329. #
  330. # Remove a module from the list
  331. #
  332. if test "x${mc_paras}" = x; then
  333. echo "${mc_pn}: error: no modules specified." 2>&1
  334. exit 1
  335. fi
  336. mc_nfmodules="${mc_fmodules}_new"
  337. # Remove trailing `.mod'
  338. mc_mods=`echo ${mc_paras} | sed -e 's/\.mod//g'`
  339. for mc_mod in ${mc_mods}; do
  340. # Remove any path information
  341. mc_mod=`echo ${mc_mod} | sed -e 's/.*\///'`
  342. echo "${mc_pn}: disabling eggdrop module: ${mc_mod}" 1>&6
  343. # Add module to the list of known modules.
  344. if grep "^${mc_mod}\.mod$" ${mc_fknownmods} 1>&7 2>&7; then
  345. if test ! -d ${mc_mod_dir}/${mc_mod}.mod; then
  346. grep -v "^${mc_mod}\.mod$" ${mc_fknownmods} \
  347. > ${mc_fknownmods}_new
  348. mv ${mc_fknownmods}_new ${mc_fknownmods}
  349. fi
  350. else
  351. if test ! -d ${mc_mod_dir}/${mc_mod}.mod; then
  352. :
  353. else
  354. echo ${mc_mod}.mod 1>> ${mc_fknownmods}
  355. fi
  356. fi
  357. # In case there are any active modules ...
  358. if test -r ${mc_fmodules}; then
  359. # Remove module from list of active modules.
  360. if grep -v "^${mc_mod}\.mod$" ${mc_fmodules} \
  361. 1> ${mc_nfmodules}
  362. then
  363. :
  364. else
  365. echo "${mc_pn}: error: building new module file failed" 1>&2
  366. echo "grepping for ${mc_mod}.mod in ${mc_fmodules} and writing to ${mc_nfmodules}"
  367. kill -STOP $$
  368. exit 1
  369. fi
  370. mv ${mc_nfmodules} ${mc_fmodules}
  371. fi
  372. done
  373. ;;
  374. xadd)
  375. #
  376. # Add a module to the list
  377. #
  378. if test "x${mc_paras}" = x; then
  379. echo "${mc_pn}: error: no modules specified." 2>&1
  380. exit 1
  381. fi
  382. # Remove trailing `.mod'
  383. mc_mods=`echo ${mc_paras} | sed -e 's/\.mod//g'`
  384. for mc_mod in ${mc_mods}; do
  385. # Remove any path information
  386. mc_mod=`echo ${mc_mod} | sed -e 's/.*\///'`
  387. # Add module to the list of known modules.
  388. if grep "^${mc_mod}\.mod$" ${mc_fknownmods} 1>&7 2>&7; then
  389. if test ! -d ${mc_mod_dir}/${mc_mod}.mod; then
  390. grep -v "^${mc_mod}\.mod$" ${mc_fknownmods} \
  391. > ${mc_fknownmods}_new
  392. mv ${mc_fknownmods}_new ${mc_fknownmods}
  393. fi
  394. else
  395. if test ! -d ${mc_mod_dir}/${mc_mod}.mod; then
  396. :
  397. else
  398. echo ${mc_mod}.mod 1>> ${mc_fknownmods}
  399. fi
  400. fi
  401. # Add module to the list of active modules.
  402. if grep "^${mc_mod}\.mod$" ${mc_fmodules} 1>&7 2>&7; then
  403. :
  404. else
  405. if test ! -d ${mc_mod_dir}/${mc_mod}.mod; then
  406. echo "${mc_pn}: warning: module does not exist: \`${mc_mod}', ignoring." 1>&2
  407. else
  408. echo "${mc_pn}: enabling eggdrop module: ${mc_mod}" 1>&6
  409. # Add it to the file
  410. echo ${mc_mod}.mod 1>> ${mc_fmodules}
  411. fi
  412. fi
  413. done
  414. ;;
  415. xclear)
  416. #
  417. # Clear list of modules
  418. #
  419. echo "${mc_pn}: cleared list of eggdrop modules." 1>&6
  420. rm -f ${mc_fmodules}
  421. touch ${mc_fmodules}
  422. ;;
  423. xupdate-depends)
  424. #
  425. # Check the dependencies and add modules which are depended on, but
  426. # aren't enabled.
  427. #
  428. mc_all_depends=
  429. mc_missing=
  430. echo ${mc_n} "calculating dependencies...${mc_c}" 1>&6
  431. # Check for selected modules
  432. if test ! -r ${mc_fmodules}; then
  433. echo " failed." 1>&6
  434. echo "${mc_pn}: error: no modules selected. You did not run configure yet." 1>&2
  435. exit 1
  436. fi
  437. mc_sel_modules=`cat ${mc_fmodules}`
  438. mc_new_mods="${mc_sel_modules}"
  439. while (test "x${mc_new_mods}" != x); do
  440. mc_mod_list="${mc_new_mods}"
  441. mc_new_mods=
  442. # Go through every module in the list
  443. for mc_mod in ${mc_mod_list}; do
  444. echo ${mc_n} ".${mc_c}" 1>&6
  445. # We have an info file, don't we?
  446. if (test ! -f ${mc_mod_dir}/${mc_mod}/modinfo); then
  447. continue
  448. fi
  449. # Figure out the module's dependencies
  450. mc_mod_depends=`grep "^DEPENDS:" ${mc_mod_dir}/${mc_mod}/modinfo | sed -e 's/^DEPENDS://'`
  451. # Check wether the dependencies are fulfilled
  452. for mc_m_depend in ${mc_mod_depends}; do
  453. if (echo ${mc_sel_modules} | \
  454. grep " ${mc_m_depend}" 1>&7 2>&7) || \
  455. (echo ${mc_sel_modules} | \
  456. grep "^${mc_m_depend}" 1>&7 2>&7)
  457. then
  458. :
  459. else
  460. # Does the module actually exist?
  461. if test ! -d ${mc_mod_dir}/${mc_m_depend}.mod
  462. then
  463. mc_missing="${mc_missing} ${mc_m_depend}"
  464. continue
  465. fi
  466. # This one is missing. Add it to the
  467. # list.
  468. mc_all_depends="${mc_all_depends} ${mc_m_depend}"
  469. mc_sel_modules="${mc_sel_modules} ${mc_m_depend}"
  470. # Add to list of modules to check in
  471. # next dependency cycle.
  472. mc_new_mods="${mc_new_mods} ${mc_m_depend}.mod"
  473. fi
  474. done
  475. done
  476. done
  477. echo " done." 1>&6
  478. # Warn about missing modules.
  479. if test "x${mc_missing}" != x; then
  480. cat 1>&2 <<EOF
  481. ${mc_pn}: warning:
  482. The following modules were not found but are needed:
  483. `echo ${mc_missing} | sed -e 's/ /, /g'`
  484. EOF
  485. echo ${mc_n} "Press enter to continue... ${mc_c}"
  486. read mc_ask_response
  487. fi
  488. if test "x${mc_all_depends}" != x; then
  489. echo ${mc_n} "adding modules needed to match dependencies... ${mc_c}" 1>&6
  490. echo ${mc_all_depends} | sed -e 's/ /, /g' 1>&6
  491. # Add the modules
  492. ${mc_self_call} -q add ${mc_all_depends}
  493. # Update the makefile
  494. ${mc_self_call} -q Makefile
  495. fi
  496. ;;
  497. xconfigure)
  498. #
  499. # Interactive module selection
  500. #
  501. cat 1>&6 <<EOF
  502. -*- Eggdrop Interactive Module Selection -*-
  503. EOF
  504. # Check for selected modules
  505. if test ! -r ${mc_fmodules}; then
  506. echo "${mc_pn}: error: no modules selected. You did not run configure yet." 1>&2
  507. exit 1
  508. fi
  509. # Read current list
  510. mc_sel_modules=`cat ${mc_fmodules}`
  511. # Detect available modules
  512. mc_mods=`echo ${mc_mod_dir}/*.mod`
  513. # Error out if we have no available modules
  514. if test "${mc_mods}" = "echo ${mc_mod_dir}/*.mod"; then
  515. echo "${mc_pn}: error: no modules found." 1>&2
  516. exit 1
  517. fi
  518. # Loop through each available module
  519. for mc_mod in ${mc_mods}; do
  520. # Remove directory information from name
  521. mc_mod=`echo ${mc_mod} | sed -e 's/.*\///'`
  522. # Only ask for new modules?
  523. if test "${mc_flag_onlynew}" = yes; then
  524. # Did we already query for that module?
  525. if grep "^${mc_mod}$" ${mc_fknownmods} 1>&7 2>&7; then
  526. continue
  527. fi
  528. fi
  529. # Remove .mod ending
  530. mc_modname=`echo ${mc_mod} | sed -e 's/\.mod//g'`
  531. # Note: We need to make sure that we only catch module names
  532. # that match _exactly_. e.g. don't mix bseen and seen.
  533. if (echo ${mc_sel_modules} | grep " ${mc_mod}" 1>&7 2>&7) ||
  534. (echo ${mc_sel_modules} | grep "^${mc_mod}" 1>&7 2>&7)
  535. then
  536. # The module is selected.
  537. mc_mstate="enabled"
  538. mc_mdisp="(E)nable / (d)isable [E/d]"
  539. else
  540. # The module is NOT selected.
  541. mc_mstate="disabled"
  542. mc_mdisp="(e)nable / (D)isable [e/D]"
  543. fi
  544. # Display description
  545. if test -r ${mc_mod_dir}/${mc_mod}/modinfo; then
  546. echo "" 1>&6
  547. grep "^DESC:" ${mc_mod_dir}/${mc_mod}/modinfo | \
  548. sed -e 's/^DESC:/ /' 1>&6
  549. echo "" 1>&6
  550. fi
  551. while true; do
  552. echo ${mc_n} "\`${mc_modname}' is ${mc_mstate}, ${mc_mdisp} ${mc_c}" 1>&6
  553. read mc_ask_response;
  554. if (test "${mc_ask_response}" = D); then
  555. mc_ask_response=d;
  556. fi
  557. if (test "${mc_ask_response}" = E); then
  558. mc_ask_response=e;
  559. fi
  560. # If the user just presses [return] or
  561. # if the selected state matches the old state,
  562. # then we change nothing.
  563. if test "x${mc_ask_response}" = x || \
  564. (test "${mc_ask_response}" = d && \
  565. test "${mc_mstate}" = disabled) || \
  566. (test "${mc_ask_response}" = e && \
  567. test "${mc_mstate}" = enabled); then
  568. echo "Changing nothing." 1>&6
  569. break;
  570. fi
  571. if (test "${mc_ask_response}" = e); then
  572. # Add it to the list.
  573. mc_sel_modules="${mc_sel_modules} ${mc_mod}"
  574. echo "Enabled module ${mc_modname}." 1>&6
  575. break;
  576. fi
  577. if (test "${mc_ask_response}" = d); then
  578. # Remove module from list.
  579. mc_sel_modules=`echo ${mc_sel_modules} | sed -e "s/ ${mc_mod}//g" -e "s/^${mc_mod}//g"`
  580. echo "Disabled module ${mc_modname}." 1>&6
  581. break;
  582. fi
  583. done
  584. echo "" 1>&6
  585. done
  586. echo ${mc_n} "recreating list of active modules... ${mc_c}" 1>&6
  587. ${mc_self_call} -q clear
  588. if (${mc_self_call} -q add ${mc_sel_modules}); then
  589. echo "done." 1>&6
  590. else
  591. echo "failed!" 1>&6
  592. exit 1
  593. fi
  594. ;;
  595. xeggautoconf)
  596. #
  597. # Recreate the eggdrop specific configure scripts for every module.
  598. #
  599. # Detect available modules
  600. mc_mods=`echo ${mc_mod_dir}/*.mod`
  601. # Error out if we have no available modules
  602. if test "${mc_mods}" = "echo ${mc_mod_dir}/*.mod"; then
  603. echo "${mc_pn}: error: no modules found." 1>&2
  604. exit 1
  605. fi
  606. # Loop through each available module
  607. for mc_modd in ${mc_mods}; do
  608. # Skip modules without their own configure script.
  609. if test ! -r "${mc_modd}/configure.in"; then
  610. continue
  611. fi
  612. # Remove directory information from name
  613. mc_mod=`echo ${mc_modd} | sed -e 's/.*\///'`
  614. echo "creating configure for module \`${mc_mod}'."
  615. (cd ${mc_modd} && ../eggautoconf)
  616. done
  617. ;;
  618. *)
  619. if test "x${mc_cmd}" = x; then
  620. echo "${mc_pn}: error: no command supplied." 1>&2
  621. else
  622. echo "${mc_pn}: error: ${mc_cmd}: unknown command." 1>&2
  623. fi
  624. ${mc_self_call} help
  625. ;;
  626. esac
  627. exit 0