summaryrefslogtreecommitdiffstats
path: root/main/iscsi-scst/iscsi-scst.initd
blob: b63a3e57d8c4e43e13387dfba7917ebe269b50e8 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
#!/sbin/runscript
#
# Start the iSCSI-SCST Target.
#

depend() {
        need net
        after firewall
}

configure_memsize() {
        if [ ! -z "$MEM_SIZE" ]; then
                if [ -e /proc/sys/net/core/wmem_max ]; then
                        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_max
                fi

                if [ -e /proc/sys/net/core/rmem_max ]; then
                        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_max
                fi

                if [ -e /proc/sys/net/core/wmem_default ]; then
                        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_default
                fi

                if [ -e /proc/sys/net/core/rmem_default ]; then
                        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_default
                fi

                if [ -e /proc/sys/net/ipv4/tcp_mem ]; then
                        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_mem
                fi

                if [ -e  /proc/sys/net/ipv4/tcp_rmem ]; then
                        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_rmem
                fi

                if [ -e /proc/sys/net/ipv4/tcp_wmem ]; then
                        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_wmem
                fi
        fi
}

check_dev_handlers() {
        if lsmod | grep "scst_" >/dev/null; then
                ewarn "Device handlers found"
        else
                ewarn "No SCST device handlers loaded!"
                ewarn "You can add them in /etc/modules"
        fi
}

start() {
        ebegin "Starting iscsi"
        check_dev_handlers
        modprobe -q crc32c
        modprobe -q iscsi-scst
        start-stop-daemon --start --exec /usr/sbin/iscsi-scstd
        /usr/sbin/scstadmin -config /etc/scst.conf
        eend 0
}

stop() {
        ebegin "Stopping iscsi"
        start-stop-daemon --stop --exec /usr/sbin/iscsi-scstd
        rmmod -w iscsi-scst
        eend 0
}