#!/bin/bash RULES_DIR="/etc/udev/rules.d/" SERVICE_DIR="/lib/systemd/system/" IPP_FILTER_DIR="/opt/pantum/ippfilter" IPPUSBXD_RULES=$IPP_FILTER_DIR/55-ippusbxd.rules IPPUSB_RULES=$IPP_FILTER_DIR/71-ipp-usb.rules IPPUSB=$IPP_FILTER_DIR/ipp-usb IPPUSB_SERVICE=$IPP_FILTER_DIR/pt-ipp-usb.service OS_NAME=$(cat /etc/os-release | grep PRETTY_NAME | awk -F "[\" ]" '{print $2}') OS_VERSION=$(cat /etc/os-release | grep VERSION_ID | awk -F \" '{print $2}') IPPUSBXD_EXIST=0 if [ -f /lib/udev/rules.d/55-ippusbxd.rules ]&&[ -f /lib/systemd/system/ippusbxd@.service ]&&[ -f /usr/sbin/ippusbxd ];then IPPUSBXD_EXIST=1 fi IPPUSB_EXIST=0 if [ -f /lib/udev/rules.d/71-ipp-usb.rules ]&&[ -f /lib/systemd/system/ipp-usb.service ]&&[ -f /sbin/ipp-usb ];then IPPUSB_EXIST=1 fi echo $OS_NAME $OS_VERSION echo "ippusbxd:$IPPUSBXD_EXIST" echo "ipp-usb:$IPPUSB_EXIST" IPPUSB_SERVICE_IS_ACTIVE=$(systemctl is-active ipp-usb) IPPUSBXD_SERVICES_BUS_DEV=$(lsusb -d 232b: | awk -F"[ :]" '{print $2":"$4}') if [ "${OS_VERSION:0:5}" == "20.04" ]&&[ "${OS_NAME:0:6}" == "Ubuntu" ]||[ $IPPUSBXD_EXIST -eq 1 ];then cp $IPPUSBXD_RULES $RULES_DIR udevadm control --reload for is in $IPPUSBXD_SERVICES_BUS_DEV do echo ippusbxd@$is.service IPPUSBXD_SERVICES_IS_ACTIVE=$(systemctl is-active ippusbxd@$is.service) echo $IPPUSBXD_SERVICES_IS_ACTIVE if [ "$IPPUSBXD_SERVICES_IS_ACTIVE" == "active" ];then echo "stop ippusbxd@$is.service" systemctl stop ippusbxd@$is.service fi done elif [ "${OS_VERSION:0:5}" == "21.10" ]||[ "${OS_VERSION:0:5}" == "22.04" ]&&[ "${OS_NAME:0:6}" == "Ubuntu" ]||[ $IPPUSB_EXIST -eq 1 ];then cp $IPPUSB_RULES $RULES_DIR cp $IPPUSB_SERVICE $SERVICE_DIR cp $IPPUSB /opt/pantum/bin/ chmod 755 /opt/pantum/bin/ipp-usb systemctl daemon-reload udevadm control --reload if [ "$IPPUSB_SERVICE_IS_ACTIVE" == "active" ];then systemctl stop ipp-usb systemctl start pt-ipp-usb fi fi echo Pantum-1.1.106-1 installed