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