Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # +-----------------------------------------------------------------------------------------+
- # | |
- # | |
- # | |
- # | |
- # | Mei 2012 flip hess [email protected] |
- # +-----------------------------------------------------------------------------------------+
- # Global variables:
- PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
- SCRIPT_PATH="${0}"
- ARGS="${#}"
- # Text color variables
- txtund=$(tput sgr 0 1) # Underline
- txtbld=$(tput bold) # Bold
- txtred=$(tput setaf 1) # Red
- txtgrn=$(tput setaf 2) # Green
- txtylw=$(tput setaf 3) # Yellow
- txtgrn=$(tput setaf 4) # Blue
- txtpur=$(tput setaf 5) # Purple
- txtcyn=$(tput setaf 6) # Cyan
- txtwht=$(tput setaf 7) # White
- txtrst=$(tput sgr0) # Text reset
- # screen size vars
- LINES=$(tput lines)
- COLUMNS=$(tput cols)
- # Functions:
- # exit function
- function die()
- {
- echo -e "Error in${SCRIPT_PATH}:\n${1}"
- exit 1
- }
- # Shows usage function.
- function fShowUsage()
- {
- echo "Usage: ${SCRIPT_PATH}"
- exit 1
- }
- # check for.......
- function fCheck()
- {
- # user must be root:
- #[ $(whoami) = root ] || die "User must be root!"
- # check for arguments:
- [ "${ARGS}" = 0 ] || fShowUsage
- # check terminal size
- [ "${COLUMNS}" -gt 90 ] || die "Terminal size is to small! Please change your terminal to at least 90 Columns"
- return 0
- }
- # function new customer
- fNewCust()
- {
- fReturn
- }
- # delete customers
- fDelCust()
- {
- fReturn
- }
- # run backup for customer
- fBackupRun()
- {
- fReturn
- return 0
- }
- # show bandwith use for customer
- fBandwidth()
- {
- { [ -x /usr/local/bin/andy/python.py ] && /usr/local/bin/andy/python.py; } || die "Failed to run /usr/local/bin/andy/python.py"
- fReturn
- return 0
- }
- # show data size for customer
- fUsed()
- {
- fReturn
- return 0
- }
- fOverview()
- {
- fReturn
- return 0
- }
- # return functie
- function fReturn()
- {
- SET=0
- while [ ${SET} = 0 ] ;
- do
- # clear screen
- clear
- # get output
- echo -e "\
- ${txtylw}######################################################################################${txtrst}\n\
- ${txtylw}# +--------------------------------------------------------------------------------+ #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | All Done! ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | Press any key to return to the menu, ${txtylw} | #${txtrst}\n\
- ${txtylw}# | Type exit to exit backup manager. ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# +--------------------------------------------------------------------------------+ #${txtrst}\n\
- ${txtylw}######################################################################################${txtrst}"
- read -p "${txtwht}${txtbld} --> " ANSWER
- # get answer
- if [ "${ANSWER}" = e ] ; then
- { echo -e "${txtred}${txtbld}Exiting in 1 seconds${txtrst}" ; sleep 0.5 ; clear ; exit 1; }
- elif [ ${ANSWER} = E ] ; then
- { echo -e "${txtred}${txtbld}Exiting in 1 seconds${txtrst}" ; sleep 0.5 ; clear ; exit 1; }
- elif [ ${ANSWER} = exit ] ; then
- { echo -e "${txtred}${txtbld}Exiting in 1 seconds${txtrst}" ; sleep 0.5 ; clear ; exit 1; }
- elif [ ${ANSWER} = EXIT ] ; then
- { echo -e "${txtred}${txtbld}Exiting in 1 seconds${txtrst}" ; sleep 0.5 ; clear ; exit 1; }
- elif [ ${ANSWER} = Exit ] ; then
- { echo -e "${txtred}${txtbld}Exiting in 1 seconds${txtrst}" ; sleep 0.5 ; clear ;exit 1; }
- else
- SET=1
- fi
- done
- # go back to menu
- [ "${SET}" = 1 ] && fStart
- }
- # function get startpage
- function fStart()
- {
- # clear screen
- clear
- # print menu
- echo -e "\
- ${txtylw}######################################################################################${txtrst}\n\
- ${txtylw}# +--------------------------------------------------------------------------------+ #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtpur} ##### ## #### # # # # ##### ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtpur} # # # # # # # # # # # # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtpur} ##### # # # #### # # # # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtpur} # # ###### # # # # # ##### ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtpur} # # # # # # # # # # # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtpur} ##### # # #### # # #### # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtred} # # ## # # ## #### ###### ##### ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtred} ## ## # # ## # # # # # # # # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtred} # ## # # # # # # # # # ##### # # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtred} # # ###### # # # ###### # ### # ##### ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtred} # # # # # ## # # # # # # # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtred} # # # # # # # # #### ###### # # ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | Mhasmo backup manger - Flip Hess Mei 2012 - [email protected] ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# |${txtgrn} 1. Een nieuwe backupklant toevoegen. ${txtylw} | #${txtrst}\n\
- ${txtylw}# |${txtgrn} 2. Een backupklant verwijderen. ${txtylw} | #${txtrst}\n\
- ${txtylw}# |${txtgrn} 3. Een backup draaien voor een klant. ${txtylw} | #${txtrst}\n\
- ${txtylw}# |${txtgrn} 4. Bandbreedte log opvragen voor een klant. ${txtylw} | #${txtrst}\n\
- ${txtylw}# |${txtgrn} 5. Dataverbruik log opvragen voor een klant. ${txtylw} | #${txtrst}\n\
- ${txtylw}# |${txtgrn} 6. Overzicht alle klanten weergeven. ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# |${txtgrn} 9. Backup manager afsluiten. ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | ${txtylw} | #${txtrst}\n\
- ${txtylw}# | Maak uw keuze door het desbetreffende nummer in te toetsen. ${txtylw} | #${txtrst}\n\
- ${txtylw}# +--------------------------------------------------------------------------------+ #${txtrst}\n\
- ${txtylw}######################################################################################${txtrst}"
- read -p "${txtwht}Wat wordt uw keuze? --> " INPUT
- #get options and set vars
- case "${INPUT}" in
- 1)
- fNewCust
- ;;
- 2)
- fDelCust
- ;;
- 3)
- fBackupRun
- ;;
- 4)
- fBandwidth
- ;;
- 5)
- fUsed
- ;;
- 6)
- fOverview
- ;;
- 9)
- exit 0
- ;;
- *)
- echo "${txtred}${txtbld}Input value not valid!${txtrst}" ; sleep 1
- fStart
- ;;
- esac
- return 0
- }
- # The main function.
- function fMain()
- {
- fStart
- return 0
- }
- # check environment:
- fCheck
- # Start the program:
- fMain "${@}"
- # Exit with previous return code:
- exit "${?}"
Advertisement
Add Comment
Please, Sign In to add comment