Skip to content

Instantly share code, notes, and snippets.

@johnhowe
Last active December 17, 2015 14:39
Show Gist options
  • Save johnhowe/5626538 to your computer and use it in GitHub Desktop.
Save johnhowe/5626538 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Starting"
#====================================================
# Added properties directory
# Updated for Eclipse plugin
# Moved shared files to /usr/local/share/usbdm
#====================================================
#================================
# USBDM Version
#
MAJOR=4
MINOR=10
LIB_SUFFIX=.so.${MAJOR}.${MINOR}
#CP_OPTIONS="-v"
CP_OPTIONS=
USBDM_CONFIG_DIRECTORY=/usr/local/share/usbdm
USBDM_PROP_DIRECTORY=$HOME/.usbdm
PROMPT_L1="This script will install the USBDM V${MAJOR}.${MINOR} files."
PROMPT_L2="Please check the contents of this file before execution. "
PROMPT_L3="This script needs to be run as root."
PROMPT_L4="use \'sudo ./Install_USBDM_Standalone\'"
PROMPT_L5="Continue (Y/N)?"
echo
echo
echo "########################################################"
echo
echo "${PROMPT_L1}"
echo
echo "${PROMPT_L2}"
echo
echo "${PROMPT_L3}"
echo "${PROMPT_L4}"
echo
echo "${PROMPT_L5}"
echo "${PROMPT_L6}"
echo
echo "########################################################"
echo
echo "${PROMPT_L7}"
read guess
if [ "$guess" != "Y" ]; then
echo "Ok I won't do anything - bye"
exit
fi
if [ -z "$SUDO_UID" ]; then
echo "This script should be run sudo"
exit 1
fi
if [ -z "$SUDO_GID" ]; then
echo "This script should be run sudo"
exit 1
fi
#echo SUDO_UID="$SUDO_UID" SUDO_GID="$SUDO_GID"
echo
echo "Copying rules file to /etc/udev/rules.d"
echo ==================================================================
cp $CP_OPTIONS bin/usbdm.rules /etc/udev/rules.d/usbdm.rules
chmod a+r /etc/udev/rules.d/usbdm.rules
echo
echo "Installing USBDM shared libraries to /usr/local/lib"
echo ==================================================================
# Earlier install?
rm /usr/local/lib/libusbdm*
# Where to copy shared libs
DEST_LIBDIR=/usr/lib
rm ${DEST_LIBDIR}/libusbdm*
# Shared libs to copy
SHARED_LIBS="libusbdm-wx libusbdm libusbdm-debug libusbdm-dsc libusbdm-dsc-debug libusbdm-tcl libusbdm-tcl-debug"
# Copy & create symbolic links
for FILE in ${SHARED_LIBS}; do
echo cp $CP_OPTIONS bin/${FILE}.so.${MAJOR}.${MINOR} ${DEST_LIBDIR}
cp $CP_OPTIONS bin/${FILE}.so.${MAJOR}.${MINOR} ${DEST_LIBDIR}
if [[ ! -e ${DEST_LIBDIR}/${FILE}.so.${MAJOR} ]]; then
ln -s ${FILE}.so.${MAJOR}.${MINOR} ${DEST_LIBDIR}/${FILE}.so.${MAJOR}
fi
if [[ ! -e ${DEST_LIBDIR}/${FILE}.so ]]; then
ln -s ${FILE}.so.${MAJOR}.${MINOR} ${DEST_LIBDIR}/${FILE}.so
fi
done
#ldconfig -v -n /usr/local/lib
ldconfig -X -v | grep usbdm
echo
echo "Installing USBDM Config files to ${USBDM_CONFIG_DIRECTORY}"
echo ==================================================================
echo
if [[ -e "${USBDM_CONFIG_DIRECTORY}" ]]; then
echo Cleaning USBDM Config Directory - ${USBDM_CONFIG_DIRECTORY}
rm -r -f "${USBDM_CONFIG_DIRECTORY}"/*
fi
if [[ ! -e "${USBDM_CONFIG_DIRECTORY}" ]]; then
echo Creating USBDM Config Directory - ${USBDM_CONFIG_DIRECTORY}
mkdir "${USBDM_CONFIG_DIRECTORY}"
else
echo USBDM Properties Config already exists - ${USBDM_CONFIG_DIRECTORY}
fi
echo "Copying Device Flash Images"
echo =====================================================================
cp -r bin/DeviceData "${USBDM_CONFIG_DIRECTORY}"
echo "Copying Device Flash Images"
echo =====================================================================
cp -r bin/FlashImages "${USBDM_CONFIG_DIRECTORY}"
chown -R "$SUDO_UID":"$SUDO_GID" "${USBDM_CONFIG_DIRECTORY}"
chmod -R a+r "${USBDM_CONFIG_DIRECTORY}"
echo
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment