Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color and systemctl install for using hauler to serve images/files #181

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@
# - https://hauler.dev
# - https://github.com/rancherfederal/hauler

# color
export RED='\x1b[0;31m'
export GREEN='\x1b[32m'
export BLUE='\x1b[34m'
export YELLOW='\x1b[33m'
export NO_COLOR='\x1b[0m'

# set functions for debugging/logging
function info {
echo && echo "[INFO] Hauler: $1"
echo && echo -e "$GREEN[INFO]$NO_COLOR Hauler: $1"
}

function verbose {
echo "$1"
echo -e "$1"
}

function warn {
echo && echo "[WARN] Hauler: $1"
echo && echo -e "$YELLOW[WARN]$NO_COLOR Hauler: $1"
}

function fatal {
echo && echo "[ERROR] Hauler: $1"
echo && echo -e "$RED[ERROR]$NO_COLOR Hauler: $1"
exit 1
}

Expand Down Expand Up @@ -137,6 +144,31 @@ case "$platform" in
;;
esac

# install systemd unit file

if [ "$platform" == linux ]; then
# create hauler dir
if [ ! -d /opt/hauler ]; then mkdir /opt/hauler ; fi

# add systemd file
cat << EOF > /etc/systemd/system/[email protected]
# /etc/systemd/system/hauler.service
[Unit]
Description=Hauler Serve %I Service

[Service]
Environment="HOME=/opt/hauler/"
ExecStart=/usr/local/bin/hauler store serve %i -s /opt/hauler/store
WorkingDirectory=/opt/hauler

[Install]
WantedBy=multi-user.target
EOF

#reload daemon
systemctl daemon-reload
fi

# clean up checksum(s)
rm -rf "hauler_${version}_checksums.txt" || warn "Failed to Remove: hauler_${version}_checksums.txt"

Expand All @@ -152,5 +184,11 @@ info "Successfully Installed at /usr/local/bin/hauler"
# display availability message
verbose "- Hauler v${version} is now available for use!"

# display systemd message
verbose "- Systemd servies are available"
verbose " cd to /opt/hauler/ and use the default store named $BLUE'store'$NO_COLOR."
verbose "- Start registry service - $BLUE'systemctl start hauler@regsitry'$NO_COLOR."
verbose "- Start fileserver service - $BLUE'systemctl start hauler@fileserver'$NO_COLOR."

# display hauler docs message
verbose "- Documentation: https://hauler.dev" && echo
info "Documentation:$BLUE https://hauler.dev $NO_COLOR" && echo
Loading