Joshun

Linux CDROM Burner Kiosk Script

Aug 10th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.77 KB | None | 0 0
  1. #!/bin/bash
  2. #Directory test - ensures that script is run from its own directory. Dialog test - ensures the 'dialog' command is installed.
  3. testdir=`ls linuxcd.sh`
  4. testdialog=`ls /usr/bin/dialog`
  5. clear
  6. if [ "$testdir" != "linuxcd.sh" ]; then echo '***Error! Script must be run from its working directory***'; exit; fi
  7. if [ "$testdialog" != "/usr/bin/dialog" ];
  8. then
  9. echo '***Error! "Dialog" is not installed.***'
  10. echo 'Install it? y/n'
  11. read installdialog
  12. if [ "$installdialog" = "y" ]; then sudo apt-get install dialog; fi
  13. exit
  14. fi
  15. #Simple kiosk-style linux distro cdrom burner
  16. #--------------------------------------------
  17. #ISO Image Paths (Symlinks in ISO folder)
  18. ubuntu=ISO/ubuntu
  19. kubuntu=ISO/kubuntu
  20. xubuntu=ISO/xubuntu
  21. opensuse=ISO/opensuse
  22. fedora=ISO/fedora
  23. debian_xfce=ISO/debian_xfce
  24. debian_kde=ISO/debian_kde
  25. pclinuxos=ISO/pclinuxos
  26. linuxmint=ISO/linuxmint
  27. #Burn Speed
  28. bspeed=10
  29. #Burn set to burn device file
  30. bdevice=`cat config/device`
  31. #Password set to password file
  32. password=`cat config/password`
  33. #Screen Resolution
  34. xres=640
  35. yres=480
  36. mheight=100
  37. #--------------------------------------------
  38. main_menu() {
  39. trap main_menu INT
  40. select=$(dialog --menu --stdout "Linux Distro Burner" "$xres" "$yres" "$mheight" 1 'Ubuntu' 2 'Kubuntu' 3 'Xubuntu' 4 'OpenSuse' 5 'Fedora' 6 'Debian XFCE' 7 'Debian KDE' 8 'PCLinuxOS' 9 'Linux Mint' 10 'Administration')
  41. if [ "$select" = "" ]; then main_menu; fi
  42. if [ "$select" = "1" ]; then bimage=$ubuntu; burn; fi
  43. if [ "$select" = "2" ]; then bimage=$kubuntu; burn; fi
  44. if [ "$select" = "3" ]; then bimage=$xubuntu; burn; fi
  45. if [ "$select" = "4" ]; then bimage=$opensuse; burn; fi
  46. if [ "$select" = "5" ]; then bimage=$fedora; burn; fi
  47. if [ "$select" = "6" ]; then bimage=$debian_xfce; burn; fi
  48. if [ "$select" = "7" ]; then bimage=$debian_kde; burn; fi
  49. if [ "$select" = "8" ]; then bimage=$pclinuxos; burn; fi
  50. if [ "$select" = "9" ]; then bimage=$linuxmint; burn; fi
  51. if [ "$select" = "10" ]; then adminauth; fi
  52. }
  53. burn() {
  54. trap main_menu INT
  55. dialog --yesno "Are you sure you wish to burn?" "$xres" "$yres"
  56. if [ "$?" = "1" ]; then main_menu; fi
  57. dialog --msgbox "Please insert a disk, and press OK..." "$xres" "$yres"
  58. clear
  59. wodim -v -pad speed=$bspeed dev=$bdevice $bimage
  60. main_menu
  61. }
  62. admin() {
  63. admin=$(dialog --menu --stdout "Administration Menu" "$xres" "$yres" "$mheight" 1 "Drop to Shell" 2 "Server Info" 3 "Reload Script" 4 "Change Password" 5 "Change CDROM Device" 6 "Return to Main Menu")
  64. if [ "$admin" = "1" ];
  65. then
  66. dialog --yesno "Are you sure? This will terminate the script." "$xres" "$yres"
  67. if [ "$?" = "1" ]; then admin; fi
  68. clear
  69. killall linuxcd.sh
  70. fi
  71. if [ "$admin" = "2" ]; then dialog --textbox "config/serverinfo" "$xres" "$yres"; admin; fi
  72. if [ "$admin" = "3" ]; then ./linuxcd.sh; fi
  73. if [ "$admin" = "4" ];
  74. then
  75. passwordchange1=$(dialog --passwordbox --stdout "Change Password" "$xres" "$yres")
  76. passwordchange2=$(dialog --passwordbox --stdout "Confirm Password" "$xres" "$yres")
  77. if [ "$passwordchange1" != "$passwordchange2" ]; then dialog --msgbox "Error - Passwords do not match" "$xres" "$yres"; admin; fi
  78. if [ "$passwordchange1" = "$passwordchange2" ]; then echo "$passwordchange1" > config/password; dialog --msgbox "Password Changed Successfully" "$xres" "$yres"; password="$passwordchange1"; admin; fi
  79. fi
  80. if [ "$admin" = "5" ]; then bdevice=$(dialog --inputbox --stdout "Enter CDROM Device" "$xres" "$yres" "$bdevice"); echo "$bdevice" > config/device; admin; fi
  81. if [ "$admin" = "6" ]; then main_menu; fi
  82. if [ "$admin" = "" ]; then main_menu; fi
  83. }
  84. adminauth() {
  85. passwordauth=$(dialog --passwordbox --stdout "Enter Password" "$xres" "$yres")
  86. if [ "$passwordauth" = "$password" ]; then admin; fi
  87. if [ "$passwordauth" != "$password" ]; then dialog --msgbox "Access Denied" "$xres" "$yres"; main_menu; fi
  88. }
  89. main_menu
Advertisement
Add Comment
Please, Sign In to add comment