From fbf1961d4edbbf8ef8a0030ae84884c000744347 Mon Sep 17 00:00:00 2001 From: Andy Clemenko Date: Fri, 16 Feb 2024 10:31:17 -0500 Subject: [PATCH 1/2] Added text color, and systemctl and notes --- install.sh | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index a7d24c76..a1ec34dc 100755 --- a/install.sh +++ b/install.sh @@ -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 } @@ -137,6 +144,31 @@ case "$platform" in ;; esac +# install systemd unit file + +if [ "$platform" == linux ]; then +# create hauler dir +mkdir /opt/hauler + +# add systemd file +cat << EOF > /etc/systemd/system/hauler@.service +# /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" @@ -152,5 +184,10 @@ info "Successfully Installed at /usr/local/bin/hauler" # display availability message verbose "- Hauler v${version} is now available for use!" +# display systemd message +verbose "- $BLUE'systemctl start hauler@regsitry'$NO_COLOR or $BLUE'systemctl start hauler@fileserver'$NO_COLOR is available" +verbose " cd to /opt/hauler/ and create a store here with the name $BLUE'store'$NO_COLOR" + + # display hauler docs message -verbose "- Documentation: https://hauler.dev" && echo +info "Documentation:$BLUE https://hauler.dev $NO_COLOR" && echo From 710f0a392b1aaa09898fe327a5245c086df40dc7 Mon Sep 17 00:00:00 2001 From: Andy Clemenko Date: Fri, 16 Feb 2024 10:53:13 -0500 Subject: [PATCH 2/2] better version --- install.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index a1ec34dc..b5a8e0ed 100755 --- a/install.sh +++ b/install.sh @@ -148,7 +148,7 @@ esac if [ "$platform" == linux ]; then # create hauler dir -mkdir /opt/hauler +if [ ! -d /opt/hauler ]; then mkdir /opt/hauler ; fi # add systemd file cat << EOF > /etc/systemd/system/hauler@.service @@ -185,9 +185,10 @@ info "Successfully Installed at /usr/local/bin/hauler" verbose "- Hauler v${version} is now available for use!" # display systemd message -verbose "- $BLUE'systemctl start hauler@regsitry'$NO_COLOR or $BLUE'systemctl start hauler@fileserver'$NO_COLOR is available" -verbose " cd to /opt/hauler/ and create a store here with the name $BLUE'store'$NO_COLOR" - +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 info "Documentation:$BLUE https://hauler.dev $NO_COLOR" && echo