File: regular-install

package info (click to toggle)
yaws 2.1.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,012 kB
  • sloc: erlang: 42,153; sh: 2,501; javascript: 1,459; makefile: 968; ansic: 890; lisp: 79; python: 34; xml: 12; php: 1
file content (132 lines) | stat: -rwxr-xr-x 4,176 bytes parent folder | download | duplicates (6)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/sh

install -d ${DESTDIR}${ETCDIR}
install -d ${DESTDIR}${LOGDIR}

# Start by detecting if systemd is used
(which systemctl && systemctl list-units) >/dev/null 2>&1
if [ $? = 0 ]; then
    install -d ${DESTDIR}${ETCDIR}/systemd/system/
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
        systemd/yaws.service > ${DESTDIR}${ETCDIR}/systemd/system/yaws.service
    exit 0
fi

# Else, looking at distro-specific files
os=$( uname -s )
which lsb_release >/dev/null 2>&1
if [ $? = 0 ]; then
    os=$( lsb_release -si )
elif [ -f /etc/os-release ]; then
    . /etc/os-release
    os=${ID}
elif [ -f /etc/arch-release ]; then
    os="arch"
elif [ -f /etc/gentoo-release ]; then
    os="gentoo"
elif [ -f /etc/fedora-release ]; then
    os="fedora"
elif [ -f /etc/centos-release ]; then
    os="centos"
elif [ -f /etc/redhat-release ]; then
    os="redhat"
elif [ -f /etc/debian_version ]; then
    os="debian"
elif [ -f /etc/SuSE-release ]; then
    os="suse"
elif [ $os = "Darwin" -a $(id -u) = 0 ]; then
    os="darwin"
elif [ $os = "FreeBSD" ]; then
    os="freebsd"
elif [ $os = "NetBSD" ]; then
    os="netbsd"
else
    os="Unknown"
fi

case $(printf $os | tr '[:upper:]' '[:lower:]') in
    debian | ubuntu)
        install -d ${DESTDIR}${ETCDIR}/init.d
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
            debian/yaws.init >  ${DESTDIR}${ETCDIR}/init.d/yaws
        chmod +x ${DESTDIR}${ETCDIR}/init.d/yaws
        ;;

    gentoo)
        # seems gentoo don't like to be installed in /usr/local/etc since #
        # /sbin/runscript still reads /etc/conf.d
        install -d ${DESTDIR}${ETCDIR}/init.d
        install -d ${DESTDIR}${ETCDIR}/conf.d
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
            gentoo/yaws.init > ${DESTDIR}${ETCDIR}/init.d/yaws
        chmod +x ${DESTDIR}${ETCDIR}/init.d/yaws
        ;;

    redhat | fedora | centos)
        install -d ${DESTDIR}${ETCDIR}/init.d
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
            redhat/yaws.init > ${DESTDIR}${ETCDIR}/init.d/yaws
        chmod +x ${DESTDIR}${ETCDIR}/init.d/yaws
        ;;

    *suse*)
        install -d ${DESTDIR}${ETCDIR}/init.d
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
            suse/yaws.init > ${DESTDIR}${ETCDIR}/init.d/yaws
        chmod +x ${DESTDIR}${ETCDIR}/init.d/yaws
        ;;


    darwin)
        startupdir="/Library/StartupItems/Yaws"
        if [ ! -e ${startupdir} ]; then
            mkdir ${startupdir};
        elif [ ! -d ${startupdir} ]; then
            echo "${startupdir} exists but is not a directory, bailing out ..."
            exit 1
        fi
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
            darwin/Yaws.StartupItem > ${startupdir}/Yaws
        chmod +x ${startupdir}/Yaws
        cp darwin/Yaws.plist ${startupdir}/StartupParameters.plist
        # MacOS is particular about the ownership of startup items.
        chown -R root:wheel ${startupdir}
        ;;

    freebsd)
        install -d ${DESTDIR}${ETCDIR}/rc.d
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
            freebsd/yaws > ${DESTDIR}${ETCDIR}/rc.d/yaws
        chmod +x ${DESTDIR}${ETCDIR}/rc.d/yaws
        ;;

    netbsd)
        sed -e "s;%prefix%;${PREFIX};g" \
            -e "s;%etcdir%;${ETCDIR};g" \
            -e "s;%bindir%;${BINDIR};g" \
            netbsd/yaws.sh > ${DESTDIR}${ETCDIR}/rc.d/yaws
        chmod +x /etc/rc.d/yaws
        ;;
    *)
        install -d ${DESTDIR}${ETCDIR}
        echo "Don't know how to make /etc/init scripts for this system"
        echo "possibly add ${PREFIX}/bin/yaws --daemon --heart to your /etc/rc.local manually"
        ;;
esac


exit 0