mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.1 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/alessandro/webmin/stone_mod_webmin.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. #
  23. # [MAIN] 80 webmin Webmin Configuration
  24. WEBMINDIR=/opt/webmin
  25. USERFILE=/etc/webmin/miniserv.users
  26. CONFFILE=/etc/webmin/miniserv.conf
  27. ACLFILE=/etc/webmin/webmin.acl
  28. set_pw() {
  29. LOGIN="$1"
  30. PASSWORD=1
  31. PASSWORD2=2
  32. while [ "$PASSWORD" != "$PASSWORD2" ] ; do
  33. gui_input "Enter $LOGIN password" "" PASSWORD ;
  34. gui_input "Re-Enter $LOGIN password" "" PASSWORD2 ;
  35. if [ "$PASSWORD" != "$PASSWORD2" ] ; then
  36. gui_message "Passwords are different: no change!"
  37. fi
  38. done
  39. if [ "$2" = 1 ] ; then
  40. gui_message "Changeing $LOGIN password."
  41. tmp="`mktemp`"
  42. sed "/^$LOGIN:.*/ s/^$LOGIN:[^:]*:/$LOGIN:`perl -e 'print crypt($ARGV[0], "XX");' "$PASSWORD"`:/ ;" < $USERFILE > $tmp
  43. cat $tmp > $USERFILE ; rm -f $tmp
  44. else
  45. gui_message "Setting $LOGIN password."
  46. perl -e 'print "$ARGV[0]:",crypt($ARGV[1], "XX"),":0::\n"' "$LOGIN" "$PASSWORD" >> $USERFILE
  47. fi
  48. }
  49. set_acl() {
  50. LOGIN="$1"
  51. ALLMODS=`echo $WEBMINDIR/*/module.info | sed -e "s,$WEBMINDIR/,,g ; s,/module.info,,g"`
  52. if [ "$2" = 1 ] ; then
  53. gui_message "Resetting $LOGIN acls to default."
  54. tmp="`mktemp`"
  55. sed "/^$LOGIN:.*/ s/:.*/: $ALLMODS/ ;" < $ACLFILE > $tmp
  56. cat $tmp > $ACLFILE ; rm -f $tmp
  57. else
  58. gui_message "Setting $LOGIN acls to default."
  59. echo "$LOGIN: $ALLMODS" >> $ACLFILE
  60. fi
  61. }
  62. set_user() {
  63. gui_input "Enter user login" "admin" LOGIN ;
  64. if [ "`grep \"^$LOGIN:\" $USERFILE`" = "" ] ; then
  65. gui_message "New user $LOGIN !"
  66. set_pw $LOGIN 0
  67. set_acl $LOGIN 0
  68. else
  69. gui_message "Existing user $LOGIN !"
  70. if gui_yesno "Change $LOGIN password?" ; then
  71. set_pw $LOGIN 1
  72. fi
  73. if gui_yesno "Reset $LOGIN acls?" ; then
  74. set_acl $LOGIN 1
  75. fi
  76. fi
  77. }
  78. edit() {
  79. gui_edit "Edit file $1" "$1"
  80. exec $STONE webmin
  81. }
  82. main() {
  83. while
  84. cmd="gui_menu webmin 'Webmin Configuration - Select an item to'"
  85. cmd="$cmd 'Add/(Re-)Set user password and acls' 'set_user'"
  86. cmd="$cmd '' '' 'Configure runlevels for webmin service'"
  87. cmd="$cmd '$STONE runlevel edit_srv webmin'"
  88. cmd="$cmd '(Re-)Start webmin init script'"
  89. cmd="$cmd '$STONE runlevel restart webmin'"
  90. cmd="$cmd '' ''"
  91. cmd="$cmd 'View/Edit $CONFFILE file' 'edit $CONFFILE'"
  92. eval "$cmd"
  93. do : ; done
  94. }