-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixownes.sh
50 lines (37 loc) · 1.97 KB
/
fixownes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
##################################################
# This BashScript is to "restore" home directories
# created when users logon. Authentications 'SSSD'.
# Directories have same name as user logon IDs.
# However changes in UserNames or when users depart
# the Organisation leaves the directory in an:
# 'orpahned' state,
# with a 'UID Number' as the Ownder,
# instead of the Logon ID of the user.
# This script is to loop through all of them,
# and basically use the directory's name itself
# to be used as the ownership of the directory.
# Group however seems to say okay i.e. gidNumber 1000,
# or "Domain Users".
# In simple layman code: we want #for FILE in *; do echo -e "$FILE\nLoops Rule\!" > $FILE; chown $FILE $FILE; done
nameofdir=""
logFile="ownershipsfix.log"
logDir=""
####################################################
# Change into new directory
cd /home/
# Generate new file list, manipulate and save
echo `date +%F` >> $logFile
ls -l >
sudo -u root obnam ls>"obnamhome-ls-$(date +%Y-%m-%d).txt"
sudo -u boudiccas obnam --config=/etc/obnam-back4.conf ls>"obnamback4-ls-$(date +%Y-%m-%d).txt"
obnam --config=/etc/obnametc.conf ls>"obnametc-ls-$(date +%Y-%m-%d).txt"
obnam --config=/etc/obnamusr.conf ls>"obnamusr-ls-$(date +%Y-%m-%d).txt"
obnam --config=/etc/obnamvar.conf ls>"obnamvar-ls-$(date +%Y-%m-%d).txt"
# Delete old backups!
find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamhome-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1
find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamback4-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1
find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnametc-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1
find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamusr-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1
find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamvar-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1
########################################################################