if which yum > /dev/null;
then
- sudo yum -y install $1
+ ${SUPER} yum -y install $1
rtrn=$?
if [ $rtrn -ne 0 ];
elif which apt-get > /dev/null;
then
- sudo apt-get -y install $1
+ ${SUPER} apt-get -y install $1
rtrn=$?
if [ $rtrn -ne 0 ];
echo "Welcome to the ${PGM_NAME} installer"
echo ""
-##############
-# Check sudo
-##############
+#############################
+# Check for root privileges
+#############################
-if ! sudo date;
-then
+SUPER=""
+
+if [ "$(id -u)" != "0" ]; then
+
+ if ! which sudo > /dev/null;
+ then
+ echo ""
+ echo "!!! ERROR !!!"
+ echo ""
+ echo "The installer requires root privileges. It is currently not"
+ echo "running as root AND the program sudo is missing from this system."
+ echo ""
+ echo "Please correct this by installing and configuring sudo or running"
+ echo "the installer as root."
+ echo ""
+ read -p "Press ENTER to exit installer:" BLAH
+ exit 1
+ fi
+
+ if ! sudo date;
+ then
+ echo ""
+ echo "!!! ERROR !!!"
+ echo ""
+ echo "Either you don't know the root password or the user is not allowed to sudo"
+ echo "Please correct this and run the installer again"
+ echo "(hint: use visudo to edit sudoers file)"
+ echo ""
+ read -p "Press ENTER to exit installer:" BLAH
+ exit 1
+ fi
+ SUPER="sudo"
+else
echo ""
- echo "!!! ERROR !!!"
+ echo "!!! Warning !!!"
echo ""
- echo "Either you don't know the root password or the user is not allowed to sudo"
- echo "Please correct this and run the installer again (hint: use visudo to edit sudoers file)"
+ echo "The installer is running as the root user which is not the prefered method."
+ echo "There are checks run at the end of the installer to help ensure proper operation"
+ echo "of ${PGM_NAME} (realtime priviledges, memory locking, frequency scaling)."
+ echo "Running as root will invalidate these tests."
echo ""
- read -p "Press ENTER to exit installer:" BLAH
- exit 1
+ read -p "Press ENTER to continue:" BLAH
+
fi
############################
;;
esac
+####################
+# Check disk space
+####################
+
+# We have to check the current folder and the INSTALL_DEST_BASE just
+# in case they are on different devices
+echo "Checking for required disk space"
+
+if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
+ echo ""
+ echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
+ echo ""
+ exit 1
+else
+ REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
+
+ #Check space in current folder
+ FREE_BYTES=$(df -B 1 ${PKG_PATH} | grep / | awk '{print $4}')
+
+ if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
+ echo ""
+ echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
+ echo ""
+ exit 1
+ fi
+
+ #Check space in INSTALL_DEST_BASE
+ FREE_BYTES=$(df -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}')
+
+ if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
+ echo ""
+ echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}"
+ echo ""
+ exit 1
+ fi
+fi
+
+#####################
+# Unpack the bundle
+#####################
+
# untar the correct bundle for us to install
echo "Unpacking bundle for $ARCH"
+
+if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
+ echo ""
+ echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
+ echo ""
+ exit 1
+fi
+
tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
echo "Running uninstaller $i"
${i}
- sudo rm -f ${i}
+ ${SUPER} rm -f ${i}
fi
done
fi
echo ""
# Copy the new version in the install directory
-sudo mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
-sudo cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
+${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
+${SUPER} cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
# write the desktop/menu file
echo "[Desktop Entry]" > /tmp/${MENU_FILE}
echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
chmod ugo+rx /tmp/${MENU_FILE}
-sudo mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
+${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
# install the Menu, Link, and Icon(s)
if [ "T" = ${HAS_XDG} ];
then
echo "Adding ${PGM_NAME} to the applications menu"
- sudo xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
- sudo xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
- sudo xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
- sudo xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
+ ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
+ ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
+ ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
+ ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
then
- sudo cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
+ ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
fi
- sudo xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
- sudo xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
+ ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
+ ${SUPER} xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
echo ""
echo "Creating a desktop link for ${PGM_NAME}"
echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
echo ""
-sudo cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
+${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
###########################
# Check Jack and qjackctl
read -p "Press ENTER to continue:" BLAH
user=`whoami`
- if sudo usermod -a -G audio $user;
+ if ${SUPER} usermod -a -G audio $user;
then
USER_GROUP_ADJUSTED="t"
else
read -p "Press ENTER to continue:" BLAH
user=`whoami`
- if sudo usermod -a -G jackuser $user;
+ if ${SUPER} usermod -a -G jackuser $user;
then
USER_GROUP_ADJUSTED="t"
else