-
Notifications
You must be signed in to change notification settings - Fork 0
/
box_maintenance
executable file
·57 lines (44 loc) · 1.23 KB
/
box_maintenance
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
51
52
53
54
55
56
#!/bin/bash
DISK1=/dev/disk/by-label/ARCHIVIO
DISK2=/dev/sda1
DISK=$DISK1
MOUNT=/media/daniele/ARCHIVIO
DELUGE_DAEMON="/home/pi/torrentbox-scripts/start_deluge"
DELUGE_USER=daniele
# stop the samba server
# service samba stop
# logger "maintenance: stopped samba server"
# stop the deluge server
killall deluged
logger "maintenance: stopped deluge daemon"
# stop plex media server
service plexmediaserver stop
logger "maintenance: stopped plex media server"
if [ -e $DISK1 ]
then
DISK=$DISK1
else
logger "$DISK1 not found, use $DISK2 as fallback"
DISK=$DISK2
fi
# finally kill all the processes accessing the disk
#fuser -m -w -k -INT $DISK
#logger "maintenance: killed processes with write access on $DISK"
# then umount the disk
umount $MOUNT
logger "maintenance: umounted $MOUNT"
# launch fsck on the block device
fsck -V -p $DISK
logger "maintenance: ran fsck on $DISK"
# re-mount the device
mount $DISK $MOUNT
logger "maintenance: mounted $DISK on $MOUNT"
# start samba service
# service samba start
# logger "maintenance: started samba service"
# start deluge daemon
su - $DELUGE_USER -c $DELUGE_DAEMON
logger "maintenance: started deluge daemon"
# start plex media server
service plexmediaserver start
logger "started plex media server"