Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- cf=""
- #Check if the number of arguments equals 1. If so, then parse the argument.
- if [ $# -eq 1 ]; then
- #Check if the argument equals "--uninstall". If so, start the uninstall process.
- if [ $1 == "--uninstall" ]; then
- #Ask if the user wants to continue.
- echo -n "Are you sure you want to continue the uninstall process, $USER? (Y/N): "; read cf
- #If the user entered "Y" or "y", then continue.
- if [ $cf == "Y" ] || [ $cf == "y" ]; then
- yes | pip uninstall pytmx
- yes | pip uninstall setuptools
- yes | sudo apt remove --force-yes python-pip
- yes | sudo apt remove --force-yes python-pygame
- exit 0
- fi
- #If the user entered "N" or "n", then abort.
- if [ $cf == "N" ] || [ $cf == "n" ]; then
- echo "Uninstall process terminated."
- exit 0
- fi
- #If the user entered an invalid answer, then abort.
- echo "Invalid answer; uninstall process aborted."
- exit 0
- fi
- #If the user entered an invalid argument, then exit.
- echo "Invalid argument."
- exit 0
- fi
- #Ask the question and respond to the answer.
- function ask_question(){
- #Ask if the user is ready to continue.
- echo -n "Are you sure you want to continue, $USER? (Y/N): "; read cf
- #If the answer is "N" or "n", then exit.
- if [ $cf == "N" ] || [ $cf == "n" ]; then
- abort
- fi
- #if the answer is "Y" or "y", then proceed.
- if [ $cf == "Y" ] || [ $cf == "y" ]; then
- install_prereqs
- fi
- #If the answer is not "N", "n", "Y", or "y", then ask the question again.
- if [ $cf != "N" ] && [ $cf != "n" ] && [ $cf != "Y" ] && [ $cf != "y" ]; then
- invalid_answer
- fi
- }
- #Abort the process.
- function abort(){
- echo "Process terminated."
- exit 0
- }
- #Install the prerequisites.
- function install_prereqs(){
- yes | sudo apt install python-pygame
- yes | sudo apt install python-pip
- pip install setuptools
- pip install pytmx
- exit 0
- }
- #Reask the question.
- function invalid_answer(){
- echo "Invalid answer."
- ask_question
- }
- #Ask the question.
- ask_question
Advertisement
Add Comment
Please, Sign In to add comment