Skip to content

Commit

Permalink
Skip Self-Update if not git clone.
Browse files Browse the repository at this point in the history
  • Loading branch information
DocDrydenn committed Oct 1, 2022
1 parent e76386c commit a492a8a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 54 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
# omsa_install.sh

Simple automated script I use to install Dell OMSA on my Dell PowerEdge R720xd and R510 servers. (might work for other series, too)

Tested on Debian-based OS's *(Debian 10, Debian 11, Ubuntu, Proxmox, etc...)*

Script will parse the Dell repo for available OMSA versions/builds and will prompt the user to select what they want.
*Note: The parsing can take up to 30 seconds... due to the Dell website, not this script.*

## Requirements:
## Requirements

- Git *(Needed for install and self-update to work)*

## Install:
This script is self-updating and uses Git commands to make the needed changes, therefore, it must be installed via a git clone.
## Install

This script is self-updating. The self-update routine uses git commands to make the update so this script should be "installed" with the below command.

`git clone https://github.com/DocDrydenn/omsa_install.git`

*(Future update will allow the user to skip the self-update function, allowing it to be "installed" and run from outside of a git clone.)*
**UPDATE: If you decide not to install via a git clone, you can still use this script, however, it will just skip the update check and continue on.**

## Usage:
```
## Usage

```bash
./omsa_install.sh [-dh]

-h | h - Display (this) Usage Output
-d | d - Enable Debug (Simulation-Only)

```

## Screenshot

![omsa_install](https://user-images.githubusercontent.com/48564375/150648855-f7de1207-dba3-44bd-b927-f559f19ade5a.png)

## References
- https://linux.dell.com/repo/community/openmanage/
- https://forum.proxmox.com/threads/dell-openmanage-on-proxmox-6-x.57932/

- <https://linux.dell.com/repo/community/openmanage/>
- <https://forum.proxmox.com/threads/dell-openmanage-on-proxmox-6-x.57932/>
100 changes: 54 additions & 46 deletions omsa_install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERS="v2.8"
VERS="v2.9"

# Set Script Variables
SCRIPT="$(readlink -f "$0")"
Expand All @@ -13,7 +13,7 @@ DEBUG=0
URL='linux.dell.com/repo/community/openmanage/'
RAW_VERSION_ARRAY=()
VERSION_ARRAY=('Cancel')
VERSION=""
#VERSION=""
RAW_BUILD_ARRAY=()
BUILD_ARRAY=('Cancel')
BUILD=""
Expand All @@ -22,33 +22,41 @@ FINAL_URL=""

# Script Update Function
self_update() {
echo "Status:"
cd "$SCRIPTPATH"
timeout 1s git fetch --quiet
timeout 1s git diff --quiet --exit-code "origin/$BRANCH" "$SCRIPTFILE"
[ $? -eq 1 ] && {
echo " ✗ Version: Mismatched."
echo "Checking for Script Updates..."
echo
echo "Fetching Update:"
if [ -n "$(git status --porcelain)" ]; # opposite is -z
then
git stash push -m 'local changes stashed before self update' --quiet
# Check if script path is a git clone.
# If true, then check for update.
# If false, skip self-update check/funciton.
if [[ -d "$SCRIPTPATH/.git" ]]; then
echo " ✓ Git Clone Detected: Checking Script Version..."
cd "$SCRIPTPATH" || exit 1
timeout 1s git fetch --quiet
timeout 1s git diff --quiet --exit-code "origin/$BRANCH" "$SCRIPTFILE"
[ $? -eq 1 ] && {
echo " ✗ Version: Mismatched"
echo
echo "Fetching Update..."
echo
if [ -n "$(git status --porcelain)" ]; then
git stash push -m 'local changes stashed before self update' --quiet
fi
git pull --force --quiet
git checkout $BRANCH --quiet
git pull --force --quiet
echo " ✓ Update Complete. Running New Version. Standby..."
sleep 3
cd - > /dev/null || exit 1

# Execute new instance of the new script
exec "$SCRIPTNAME" "${ARGS[@]}"

# Exit this old instance of the script
exit 1
}
echo " ✓ Version: Current"
else
echo " ✗ Git Clone Not Detected: Skipping Update Check"
fi
git pull --force --quiet
git checkout $BRANCH --quiet
git pull --force --quiet
echo " ✓ Update: Complete."
echo
echo "Launching New Version. Standby..."
sleep 3
cd - > /dev/null # return to original working dir
exec "$SCRIPTNAME" "${ARGS[@]}"

# Now exit this old instance
exit 1
}
echo " ✓ Version: Current."
echo
}

# Error Trapping with Cleanup Function
Expand All @@ -75,7 +83,7 @@ createmenu_version ()
then
#echo "You selected $option which is option $REPLY"
USR_VER_URL=$URL$option
VERSION=${option%?}
#VERSION=${option%?}
break;
else
echo "Incorrect Input: Select a number 1-$#"
Expand Down Expand Up @@ -155,11 +163,11 @@ usage_example() {
trap 'errexit' ERR

# Parse Commandline Arguments
([ "$1" = "-h" ] || [ "$1" = "h" ]) && usage_example
([ "$2" = "-h" ] || [ "$2" = "h" ]) && usage_example
{ [ "$1" = "-h" ] || [ "$1" = "h" ]; } && usage_example
{ [ "$2" = "-h" ] || [ "$2" = "h" ]; } && usage_example

([ "$1" = "d" ] || [ "$1" = "-d" ]) && DEBUG=1
([ "$2" = "d" ] || [ "$2" = "-d" ]) && DEBUG=1
{ [ "$1" = "d" ] || [ "$1" = "-d" ]; } && DEBUG=1
{ [ "$2" = "d" ] || [ "$2" = "-d" ]; } && DEBUG=1

# Opening Intro
clear
Expand All @@ -174,7 +182,7 @@ phaseheader $PHASE
sleep 1
#===========================================================================================================================================
# Self Update
self_update
#self_update

### End Phase 0
phasefooter $PHASE
Expand All @@ -194,7 +202,7 @@ IFS=$'\n' read -r -d '' -a RAW_VERSION_ARRAY < <( wget -q $URL -O - | tr "\t\r\n
# Parse for Versions
for i in "${RAW_VERSION_ARRAY[@]}"
do
[[ $i == [0-9]* ]] && [[ ${#i} -gt 2 ]] && VERSION_ARRAY+=($i)
[[ $i == [0-9]* ]] && [[ ${#i} -gt 2 ]] && VERSION_ARRAY+=("$i")
done

# Prompt for Desired Version
Expand All @@ -210,7 +218,7 @@ IFS=$'\n' read -r -d '' -a RAW_BUILD_ARRAY < <( wget -q $USR_VER_URL -O - | tr "
# Parse for Builds
for i in "${RAW_BUILD_ARRAY[@]}"
do
[[ $i == [a-z]* ]] && BUILD_ARRAY+=($i)
[[ $i == [a-z]* ]] && BUILD_ARRAY+=("$i")
done

# Prompt for Desired Build
Expand Down Expand Up @@ -269,7 +277,7 @@ else
wget https://linux.dell.com/repo/pgp_pubkeys/0x1285491434D8786F.asc
apt-key add 0x1285491434D8786F.asc
apt update
rm $SCRIPTPATH/0x1285491434D8786F.asc
rm "$SCRIPTPATH/0x1285491434D8786F.asc"
fi

### End Phase 2
Expand Down Expand Up @@ -338,16 +346,16 @@ else
dpkg -i libsfcutil0_1.0.1-0ubuntu4_amd64.deb
dpkg -i sfcb_1.4.9-0ubuntu5_amd64.deb
dpkg -i libcmpicppimpl0_2.0.3-0ubuntu2_amd64.deb
rm $SCRIPTPATH/libwsman-curl-client-transport1_2.6.5-0ubuntu3_amd64.deb
rm $SCRIPTPATH/libwsman-client4_2.6.5-0ubuntu3_amd64.deb
rm $SCRIPTPATH/libwsman1_2.6.5-0ubuntu3_amd64.deb
rm $SCRIPTPATH/libwsman-server1_2.6.5-0ubuntu3_amd64.deb
rm $SCRIPTPATH/libcimcclient0_2.2.8-0ubuntu2_amd64.deb
rm $SCRIPTPATH/openwsman_2.6.5-0ubuntu3_amd64.deb
rm $SCRIPTPATH/cim-schema_2.48.0-0ubuntu1_all.deb
rm $SCRIPTPATH/libsfcutil0_1.0.1-0ubuntu4_amd64.deb
rm $SCRIPTPATH/sfcb_1.4.9-0ubuntu5_amd64.deb
rm $SCRIPTPATH/libcmpicppimpl0_2.0.3-0ubuntu2_amd64.deb
rm "$SCRIPTPATH/libwsman-curl-client-transport1_2.6.5-0ubuntu3_amd64.deb"
rm "$SCRIPTPATH/libwsman-client4_2.6.5-0ubuntu3_amd64.deb"
rm "$SCRIPTPATH/libwsman1_2.6.5-0ubuntu3_amd64.deb"
rm "$SCRIPTPATH/libwsman-server1_2.6.5-0ubuntu3_amd64.deb"
rm "$SCRIPTPATH/libcimcclient0_2.2.8-0ubuntu2_amd64.deb"
rm "$SCRIPTPATH/openwsman_2.6.5-0ubuntu3_amd64.deb"
rm "$SCRIPTPATH/cim-schema_2.48.0-0ubuntu1_all.deb"
rm "$SCRIPTPATH/libsfcutil0_1.0.1-0ubuntu4_amd64.deb"
rm "$SCRIPTPATH/sfcb_1.4.9-0ubuntu5_amd64.deb"
rm "$SCRIPTPATH/libcmpicppimpl0_2.0.3-0ubuntu2_amd64.deb"
fi

### End Phase 3
Expand Down

0 comments on commit a492a8a

Please sign in to comment.