Question: Write a bash script that provides a simple text - based menu allowing users to choose between starting, stopping, restarting, enabling, and checking the status
Write a bash script that provides a simple textbased menu allowing users to choose between
starting, stopping, restarting, enabling, and checking the status of a system service. When your
script starts, its user menu should look like this:
SERVICESCRIPTMENU
Start a service.
Stop a service.
Restart a service.
Enable a service.
Check a services status.
Clear screen.
Exit script.
Please choose an option by entering its number ie:
Each option should do the following:
Start a service: This option should do the following:
o Request a service name from the user and use systemctl to start it
o Check if this command had an exit code of If it did, print a message saying that
the service was successfully started.
If the code was not print a message saying that the command failed.
Stop a service: Use the same logic as the first option, only use systemctl to stop the
service.
Restart a service: Use the same logic as the first option, only use systemctl to restart the
service.
Enable a service: Use the same logic as the first option, only use systemctl to enable the
service.
Check a services status: As with the other options, request a service name and use the
systemctl command to check the services status, printing the output to the screen.
Clear screen: Use the clear command to clear the screen.
Exit script: Terminate the script.
For options the script should reprint or return to the menu and allow the user to select
another option after the previous one is completed. Options should print a success or failure
message before doing this. The script should only quit when the user enters option or
terminates it manually eg Ctrl C
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
