|

Below is my Computeach UNIX assignment for Stage 4a, this assignment
achived a 100% pass mark. Please note it uses some shell scripting
methods not taught by Computeach.
Task
One
A suitable
directory hierarchy for the given application:-

Commands
that could be used to create this directory structure:-
cd
/usr
mkdir LM4792
cd
LM4792
mkdir wp
mkdir invoice
mkdir sales-ledger
mkdir stock-control
cd
wp
mkdir managers
mkdir staff
mkdir general
Task Two
Below
is a suitable shell script called mymenu to create the above menu
system and accept a suitable response to activate each option or
sub-menu. All responses are validated. Download
this code.
#!/bin/sh
#
A script to display a menu on the screen and accept only valid
# options from the user. - Mr Len Meakin - #**4792 - 22-12-2001
#
Clear the screen of any previous output
clear
#Set
choice to "" so loop continues looking for a correct response
choice=""
while [ "$choice" = "" ]; do
echo " Computeach UNIX Menu Option system"
echo " =================================="
echo " Please choose an option from those
listed below"
echo ""
echo ""
echo " 1] Word Processing"
echo " 2] Invoicing"
echo " 3] Sales Ledger"
echo " 4] Stock Control"
echo " 5] Utilities..."
echo " 6] Shutdown System"
echo ""
# -n option so input can
be entered on the same line
echo -n " Enter your choice [1-6] - "
read choice
echo
""
# Check input and display
what is about to happen
case $choice in
1) echo " Word Processing
Selected" # OfficeStar
;;
2) echo " Invoicing Selected"
;;
3) echo " Sales Ledger
Selected"
;;
4) echo " Stock Control
Selected"
;;
5) echo " Entering Utilities
Menu..."
;;
6) echo " Attempting to
shutdown the system..."
;;
*) echo " Incorrect input
'$choice', Please try again..."
#
Set choice to "" so loop continues
choice=""
#
Display message for 2 seconds then continue asking
sleep 2
clear
;;
esac
done
echo "" # Blank line before returning
back to the shell prompt
# End of script
Task Three
The
following working groups need creating:-
manger
staff
general
The
commands required to create these working groups are as follows:-
groupadd
manager
groupadd staff
groupadd general
The
following uses are to be added to the system:-
| Name |
UserID |
Password |
Group |
Home
Directory |
| Bill
Gates |
bg |
pop110smtp |
manager,staff,general |
/usr/home/bg |
| Fred
Bloggs |
fb |
helo25box |
staff,general |
/usr/home/fb |
| Pete
Smith |
ps |
hal41goo |
staff,general |
/usr/home/ps |
| Genny
Moore |
gm |
thump28hit |
staff,general |
/usr/home/gm |
| Phil
Royle |
pr |
der45low |
staff,general |
/usr/home/pr |
| Len
Meakin |
lm |
fre09234di |
manager,staff,general |
/usr/home/lm |
Set the correct permissions on the directories created in task one,
with the following commands:-
chown
:manager /usr/LM4792/wp/managers
chown :staff /usr/LM4792/wp/staff
chown :general /usr/LM4792/wp/general
Prevent
other users viewing the contents of the directories.
chmod
770 /usr/LM4792/wp/managers
chmod 770 /usr/LM4792/wp/staff
chmod 770 /usr/LM4792/wp/general
Add the above users to the system.
useradd -g manager
-G manager,staff,general -d /usr/home/bg -s /bin/bash -m -c "Bill
Gates" bg
passwd bg
pop110smtp
(entered twice when requested)
useradd -g staff
-G staff,general -d /usr/home/fb -s /bin/bash -m -c "Fred Bloggs"
fb
passwd fb
helo25box
(entered twice when requested)
useradd -g staff
-G staff,general -d /usr/home/ps -s /bin/bash -m -c "Pete Smith"
ps
passwd ps
hal41goo
(entered twice when requested)
useradd -g staff
-G staff,general -d /usr/home/gm -s /bin/bash -m -c "Genny
Moore" gm
passwd gm
thump28hit
(entered twice when requested)
useradd -g staff
-G staff,general -d /usr/home/pr -s /bin/bash -m -c "Phil Royle"
pr
passwd pr
der45low
(entered twice when requested)
useradd -g manager
-G manager,staff,general -d /usr/home/lm -s /bin/bash -m -c "Len
Meakin" lm
passwd lm
free22love (entered
twice when requested)
Task Four
A suitable
script that will backup all data files in the Sales Ledger directory
could be as shown below. This script does assume that a default
tape drive is already specified with in the file [ /etc/default/tar
]:-
#!/bin/sh
#
A script for Computeach that backs up the /usr/LM4792/sales-ledger
# directory to a
# pre-installed tape archiving system.
# This script is then to be called on a daily and weekly basis by
# using crontab
tar -cv /usr/LM4792/sales-ledger
#
End of script
Entry
into crontab so that
the /root/backup
script is run on a daily and monthly basis:-
crontab
-e
Then
within the vi editor:-
Press I to enter insert mode then enter the following line for the
daily backup (1.00 am daily):-
0
1 * * * /root/backup
Then
enter the following line for the weekly backup (every Sunday at
2.00am):-
0
2 * * 0 /root/backup
Then
press [ESC] to quit
insert mode.
Then enter :wq to
save the file and exit out of
vi.
Back Home
|