modconfig 18 KB

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