Radiation-resistantCamera/Vimba_6_0/VimbaCSITL/Install.sh
2025-04-30 09:26:04 +08:00

117 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
#==============================================================================
# Copyright (C) 2013 - 2021 Allied Vision Technologies. All Rights Reserved.
#
# Redistribution of this file, in original or modified form, without
# prior written consent of Allied Vision Technologies is prohibited.
#
#------------------------------------------------------------------------------
#
# File: Install.sh
#
# Description: Setup script for creating a startup script that exports the
# GENICAM_GENTL32_PATH and GENICAM_GENTL64_PATH variable
#
#------------------------------------------------------------------------------
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
# NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#==============================================================================
CWD=$(dirname $(readlink -f $0))
UNAME=$(uname -m)
if [ ${UNAME} = i386 ]
then
ARCH=x86
WORDSIZE=32
elif [ ${UNAME} = i486 ]
then
ARCH=x86
WORDSIZE=32
elif [ ${UNAME} = i586 ]
then
ARCH=x86
WORDSIZE=32
elif [ ${UNAME} = i686 ]
then
ARCH=x86
WORDSIZE=32
elif [ ${UNAME} = x86_64 ]
then
ARCH=x86
WORDSIZE=both
elif [ ${UNAME} = amd64 ]
then
ARCH=x86
WORDSIZE=both
elif [ ${UNAME} = armv6l ]
then
ARCH=arm
WORDSIZE=32
elif [ ${UNAME} = armv7l ]
then
ARCH=arm
WORDSIZE=32
elif [ ${UNAME} = aarch64 ]
then
ARCH=arm
WORDSIZE=$(getconf LONG_BIT)
else
echo "Error: Incompatible system architecture found." 1>&2
exit 1
fi
# Make sure our script is only being run with root privileges
if [ "$(id -u)" != "0" ];
then
echo "Error: This script must be run with root privileges." 1>&2
exit 1
fi
TL_NAME=VimbaCSITL
PROFILE_FOLDER=/etc/profile.d
if [ ${WORDSIZE} = 32 ] || [ ${WORDSIZE} = both ]
then
TL_PATH_32BIT=$CWD/CTI/${ARCH}_32bit
if [ -d "$TL_PATH_32BIT" ]; then
TL_SCRIPT_32BIT=${PROFILE_FOLDER}/${TL_NAME}_32bit.sh
echo "Registering GENICAM_GENTL32_PATH"
printf "#!/bin/sh\n\n#Do not edit this file manually because it may be overwritten automatically.\nexport GENICAM_GENTL32_PATH=\$GENICAM_GENTL32_PATH:\"%s\"" $TL_PATH_32BIT > $TL_SCRIPT_32BIT
chmod +x $TL_SCRIPT_32BIT
fi
fi
if [ ${WORDSIZE} = 64 ] || [ ${WORDSIZE} = both ]
then
TL_PATH_64BIT=$CWD/CTI/${ARCH}_64bit
if [ -d "$TL_PATH_64BIT" ]; then
TL_SCRIPT_64BIT=${PROFILE_FOLDER}/${TL_NAME}_64bit.sh
echo "Registering GENICAM_GENTL64_PATH"
printf "#!/bin/sh\n\n#Do not edit this file manually because it may be overwritten automatically.\nexport GENICAM_GENTL64_PATH=\$GENICAM_GENTL64_PATH:\"%s\"" $TL_PATH_64BIT > $TL_SCRIPT_64BIT
chmod +x $TL_SCRIPT_64BIT
fi
fi
LIMITS_DIR=/etc/security/limits.d
VIMBA_GROUP=vimba
mkdir -p "${LIMITS_DIR}"
echo -e "@${VIMBA_GROUP}\t-\trtprio\t99" >"${LIMITS_DIR}/${VIMBA_GROUP}.conf"
groupadd vimba 2>/dev/null
USERNAME="$(getent passwd 1000 | cut -d: -f1)"
echo "Done"
echo -e '\033[31mIMPORTANT:\033[0m For best performance, add all users who will use the CSI transport layer to group '"'"'vimba'"'"
echo " for example: sudo usermod -a -G vimba ${USERNAME:-${USER}}"
echo "Please log off once before using the CSI transport layer"