Created
April 18, 2024 14:07
-
-
Save marshki/5eb20e04142f7bcde18953867f94d549 to your computer and use it in GitHub Desktop.
BigFix auto installer for GNU/Linux (Ubuntu OS), written in Bash.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# Set 'Computer Name' to serial number. | |
# Download, unzip, install, and cleanup BigFix GNU/Linux. | |
# | |
# Author: M. Krinitz <mjk235 [at] nyu [dot] edu> | |
# Date: 2023-11-08 | |
# License: MIT | |
######### | |
# Globals | |
######### | |
# URL. | |
URL="" | |
# Zip file. | |
FILE="fixer.zip" | |
# Name of currently logged in user. | |
USER=$(logname) | |
# Components of .zip package. | |
BIGFIX_COMPONENT=( | |
actionsite.afxm | |
BESAgent-11.0.0.175-ubuntu18.amd64.deb | |
) | |
######## | |
# Fixer. | |
######## | |
# Is current UID 0? If not, exit. | |
root_check() { | |
if [ "$EUID" -ne "0" ] ; then | |
printf "%s\n" "Error: root privileges are required to continue." "Try: sudo bash fixer.sh" >&2 | |
exit 1 | |
fi | |
} | |
# Get serial number. | |
get_serial_number() { | |
serialnum=$(dmidecode -s system-serial-number) | |
} | |
# Get computer name. | |
get_computer_name() { | |
computername=$(hostname) | |
} | |
# Set computer name to serial number. | |
set_computer_name() { | |
if [ "$serialnum" != "$computername" ]; then | |
printf "%s\n" "Setting 'Computer Name'..." | |
hostnamectl set-hostname "$serialnum" | |
fi | |
} | |
# Create directory: BESClient. | |
make_directory() { | |
printf "%s\n" "Creating BESClient directory..." | |
mkdir -pv /etc/opt/BESClient | |
} | |
# Download BigFix client .zip to the client. | |
retrieve_zip() { | |
printf "%s\n" "Retrieving .zip file..." | |
wget --progress=bar --tries=3 --wait=5 --continue "$URL/$FILE" --output-document=/home/"$USER/$FILE" | |
} | |
# Unzip BigFix client .zip file..." | |
unzip_zip() { | |
printf "%s\n" "Unpacking .zip file..." | |
unzip /home/"$USER/$FILE" -d /home/"$USER" | |
} | |
# Install the .deb package. | |
install_deb() { | |
printf "%s\n" "Installing BigFix .deb..." | |
dpkg --install /home/"$USER"/"${BIGFIX_COMPONENT[1]}" | |
} | |
# Copy actionsite masthead to: /etc/opt/BESClient. | |
copy_masthead() { | |
printf "%s\n" "Copying masthead to: /etc/opt/BESClient..." | |
cp -rv /home/"$USER"/"${BIGFIX_COMPONENT[0]}" /etc/opt/BESClient | |
} | |
# Create besclient.config file and insert 'Federated Tags' in to the same. | |
insert_tags() { | |
printf "%s\n" "Inserting federated tags..." | |
cat > /var/opt/BESClient/besclient.config << EOF | |
[Software\BigFix\EnterpriseClient] | |
EnterpriseClientFolder = /opt/BESClient | |
[Software\BigFix\EnterpriseClient\GlobalOptions] | |
StoragePath = /var/opt/BESClient | |
LibPath = /opt/BESClient/BESLib | |
[Software\BigFix\EnterpriseClient\Settings\Client\FederatedTag] | |
value = PsychCNS | |
[Software\BigFix\EnterpriseClient\Settings\Client\_BESClient_Download_NormalStageDiskLimitMB] | |
value = 10240 | |
EOF | |
} | |
# Start the BigFix client. | |
start_bigfix() { | |
printf "%s\n" "Starting BigFix..." | |
/etc/init.d/besclient start | |
} | |
# Main. | |
main() { | |
root_check | |
get_serial_number | |
get_computer_name | |
#set_computer_name | |
make_directory | |
retrieve_zip | |
unzip_zip | |
install_deb | |
copy_masthead | |
insert_tags | |
start_bigfix | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment