Root/ibrdtnd/files/systemcheck.sh

1#!/bin/sh
2#
3#
4
5check_mounted() {
6    DIR=$1
7    while [ "$DIR" != "/" ]; do
8        if [ -n "`mount | grep "$DIR"`" ]; then
9            return 0
10        fi
11
12        DIR=`dirname $DIR`
13    done
14    return 1
15}
16
17check_writable() {
18    CHECKFILE="$1/.container-lock"
19    /bin/touch $CHECKFILE
20
21    if [ $? -gt 0 ]; then
22        return 1;
23    fi
24
25    /bin/echo "0123456789" >> $CHECKFILE
26
27    if [ $? -gt 0 ]; then
28        return 2;
29    fi
30
31    /bin/rm $CHECKFILE
32
33    if [ $? -gt 0 ]; then
34        return 3;
35    fi
36}
37
38# get the path for the container
39CONTAINER=`uci -q get ibrdtn.storage.container`
40
41if [ -z "$CONTAINER" ]; then
42    exit 0
43fi
44
45CONTAINER_PATH=`dirname $CONTAINER`
46
47if [ -n "$CONTAINER_PATH" ]; then
48    # check if the container is on a mounted device
49    check_mounted $CONTAINER_PATH
50
51    if [ $? -gt 0 ]; then
52        # failed
53        exit 1
54    fi
55
56    # check if the device is writable
57    check_writable $CONTAINER_PATH
58
59    if [ $? -gt 0 ]; then
60        # failed
61        exit 1
62    fi
63fi
64
65

Archive Download this file



interactive