#!/bin/bash
# Generated installation script to install LinX-Base v2.2.8 on CCpilot VA

# RED='\033[0;31m'
# GREEN='\033[0;32m'
# YELLOW='\033[1;33m'
# NC='\033[0m' # No Color

# INSTALLATION_SUCCESS=0

# verify_installation() {
	# ERROR=$1
	# SCRIPT=$2

	# if [ ${ERROR} -eq 1 ]; then
		# echo -e "${RED}Failed installation $SCRIPT${NC}";
		# echo "";
		# echo "Installation aborted!";
		# echo "";
		# exit 1;
	# else
		# echo -e "${GREEN}Installed $SCRIPT${NC}";
	# fi
# }

#Remove old Qt5-runtime to free up space
rm -rf /opt/Qt-5.4.0

cd /media/usb/LinXTmpData

chmod +x Qt5.6.3_profile-patch_ARM_1.0.1_install.sh
./Qt5.6.3_profile-patch_ARM_1.0.1_install.sh
#verify_installation $? Qt_profile_Patch_package

chmod +x Qt5.6.3_uuid-patch_ARM_1.0.0_install.sh
./Qt5.6.3_uuid-patch_ARM_1.0.0_install.sh
#verify_installation $? Qt_uuid_Patch_package

chmod +x Qt5.6.3_ld.so.conf-patch_ARM_1.0.0_install.sh
./Qt5.6.3_ld.so.conf-patch_ARM_1.0.0_install.sh
#verify_installation $? Qt_ldConf_Patch_package

chmod +x imx5_LinX-Components.sh
./imx5_LinX-Components.sh
#verify_installation $? Linx_lib_package

chmod +x firebird2.5-superclassic_2.5.2.26540_arm.sh
./firebird2.5-superclassic_2.5.2.26540_arm.sh
#verify_installation $? Firebird_package

chmod +x installDataEngineServer_ARM.sh
./installDataEngineServer_ARM.sh
#verify_installation $? DataEngine_package

chmod +x installFieldbusAccess_ARM.sh
./installFieldbusAccess_ARM.sh
#verify_installation $? FieldbusAccess_package

chmod +x Qt-5.6.3_ARM_VA_install.sh
./Qt-5.6.3_ARM_VA_install.sh
#verify_installation $? Qt5_runtime_package

chmod +x Qt5FramebufferFix_1.0.0_install.sh
./Qt5FramebufferFix_1.0.0_install.sh
#verify_installation $? Framebuffer_package

chmod +x Qt5EvdevTouchParameters.sh
./Qt5EvdevTouchParameters.sh
#verify_installation $? Evdevtouch_package

chmod +x StartupGuiQt5_ARM_1.0.1_install.sh
./StartupGuiQt5_ARM_1.0.1_install.sh
#verify_installation $? Qt5AutostartScript_package

mv /opt/etc/rc3.d/S17StartupDataEngineServer /opt/etc/rc3.d/S26StartupDataEngineServer
cd ..

#Remove unpacked packages to free up space
echo "Remove temporary files used during installation"
#rm -rf LinXTmpData

# Create a stamp to indicate installed package
touch /opt/packages/LinX-Base_VA_device_v2.2.8

# echo "The following packages were found and sucessfully installed:"
# echo -e "${YELLOW}$(ls /opt/packages)${NC}"
# echo ""
# echo -e "Installation ${GREEN}SUCCESSFUL!${NC}\n"
# echo ""
exit $INSTALLATION_SUCCESS
