modconfig 18 KB

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