6aa1779a3311f3007274558f8e4ef3fc8ed19302
[webi-installers/.git] / serviceman / serviceman.bash
1 #!/bin/bash
2
3 # title: Serviceman
4 # homepage: https://git.rootprojects.org/root/serviceman
5 # tagline: cross-platform service management for Linux, Mac, and Windows
6 # description: |
7 #   Works with
8 #   - Launchd (macOS)
9 #   - Systemd (Linux)
10 #   - Windows Registry
11
12 set -e
13 set -u
14
15 # Get arch envs, etc
16 my_url="https://rootprojects.org/serviceman/dist/$(uname -s)/$(uname -m)/serviceman"
17 curl -fL "$my_url" -o serviceman
18 echo ""
19 # Make executable
20 chmod +x ./serviceman
21 # Move to ~/.local/bin
22 mkdir -p ~/.local/bin
23 mv ./serviceman ~/.local/bin
24
25 # Test if in PATH
26 set +e
27 my_serviceman=$(command -v serviceman)
28 set -e
29 if [ -n "$my_serviceman" ]; then
30         if [ "$my_serviceman" != "$HOME/.local/bin/serviceman" ]; then
31                 echo "a serviceman installation (which make take precedence) exists at:"
32                 echo "    $my_serviceman"
33                 echo ""
34         fi
35 fi
36
37 # add to ~/.local/bin to PATH, just in case
38 pathman add ~/.local/bin # > /dev/null 2> /dev/null
39 # TODO inform user to add to path, apart from pathman?