Project

General

Profile

rc.d-minio.txt

Michael Reynolds, 07/03/2018 01:58 PM

 
1
[root@freenas ~]# cat /usr/local/etc/rc.d/minio
2
#!/bin/sh
3

    
4
# PROVIDE: minio
5
# KEYWORD: shutdown
6

    
7
#
8
# Add the following lines to /etc/rc.conf to enable minio:
9
#
10
# minio_enable (bool):          Set to "NO" by default.
11
#                               Set it to "YES" to enable minio
12
# minio_config (path):          Set to "/usr/local/etc/minio" by default
13
#                               Set to directory to store minio config
14
# minio_disks (path):           Set to "/var/db/minio" by default.
15
#                               Set it to directory to store minio data
16
# minio_address (str):          Set to ":9000" by default.
17
#                               Set it to address for minio to listen on
18
# minio_user (str):             Set to "minio" by default.
19
#                               Set it to user to run minio under
20
# minio_group (str):            Set to "minio" by default.
21
#                               Set it to group to run minio under
22
# minio_logfile (str):          Set to "/var/log/minio.log" by default.
23
#                               Set it to file where stdout/stderr are logged.
24
#
25

    
26
. /etc/rc.subr
27

    
28
name=minio
29
rcvar=minio_enable
30

    
31
load_rc_config ${name}
32

    
33
: ${minio_enable:="NO"}
34
: ${minio_config="/usr/local/etc/minio"}
35
: ${minio_disks="/var/db/minio"}
36
: ${minio_address=":9000"}
37
: ${minio_user:="minio"}
38
: ${minio_group:="minio"}
39
: ${minio_logfile:="/var/log/minio.log"}
40

    
41
pidfile="/var/run/${name}.pid"
42
procname="/usr/local/bin/minio"
43
command="/usr/sbin/daemon"
44
command_args="-c -p ${pidfile} /usr/bin/env ${minio_env} ${procname} -C \"${minio_config}\" server --address=\"${minio_address}\" --quiet ${minio_disks} < /dev/null > ${minio_logfile} 2>&1"
45

    
46
start_precmd="minio_startprecmd"
47

    
48
minio_startprecmd()
49
{
50
        if [ ! -e "${pidfile}" ]; then
51
                install -o "${minio_user}" -g "${minio_group}" "/dev/null" "${pidfile}"
52
        fi
53

    
54
        if [ ! -d "${minio_config}" ]; then
55
                install -d -o "${minio_user}" -g "${minio_group}" "${minio_config}"
56
        fi
57

    
58
        if [ ! -e "${minio_logfile}" ]; then
59
                install -o "${minio_user}" -g "${minio_group}" "/dev/null" "${minio_logfile}"
60
        fi
61

    
62
        if [ -d "${minio_config}" -a "$(stat -f '%p' "${minio_config}")" != "40775" ]; then
63
                chmod 775 "${minio_config}"
64
        fi
65

    
66
        for disk in "${minio_disks}"; do
67
                if [ ! -d "${disk}" ]; then
68
                        install -d -o "${minio_user}" -g "${minio_group}" "${disk}"
69
                fi
70
        done
71
}
72

    
73
run_rc_command "$1"