Last active
October 29, 2024 19:19
-
-
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 | |
# | |
# mixer | |
# | |
# Download, unzip, and install BigFix in GNU/Linux. | |
# 'Computer Name' is set to serial number in this script. | |
# | |
# Author: M. Krinitz <mjk235 [at] nyu [dot] edu> | |
# Date: 2024-10-28 | |
# License: MIT | |
######### | |
# Globals | |
######### | |
# URL of server hosting installer. | |
URL="" | |
# Zip file. | |
FILE="mixer.zip" | |
# Name of currently logged in user. | |
USER=$(logname) | |
# Components of .zip package. | |
BIGFIX_COMPONENT=( | |
actionsite.afxm | |
BESAgent-11.0.3.82-ubuntu18.amd64.deb | |
) | |
######## | |
# Mixer. | |
######## | |
# 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 mixer.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" | |
hostnamectl set-hostname "$serialnum" --pretty | |
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