mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
lirc: simplify scripts
This commit is contained in:
parent
8e51cee404
commit
64a31b5378
@ -17,52 +17,45 @@
|
|||||||
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ACTION=$(echo "$1")
|
DEVICE=$(echo "$1" | cut -f1 -d:)
|
||||||
DEVICE=$(echo "$2" | cut -f1 -d:)
|
DRIVER=$(echo "$1" | cut -f2 -d:)
|
||||||
DRIVER=$(echo "$2" | cut -f2 -d:)
|
CONFIG=$(echo "$1" | cut -f3 -d:)
|
||||||
CONFIG=$(echo "$2" | cut -f3 -d:)
|
|
||||||
|
|
||||||
case "$ACTION" in
|
if [ "x$DRIVER" = "x" ]; then
|
||||||
add)
|
exit 1;
|
||||||
if [ "x$DRIVER" = "x" ]; then
|
fi
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p '/run/lirc'
|
mkdir -p '/run/lirc'
|
||||||
|
|
||||||
if [ ! -e "/run/lirc/lircd-$DEVICE.pid" ]; then
|
LIRCD="/usr/sbin/lircd"
|
||||||
|
LIRCD_UINPUT="/usr/sbin/lircd-uinput"
|
||||||
|
LIRCD_CONFIG="--driver=$DRIVER --device=/dev/$DEVICE"
|
||||||
|
LIRCD_CONFIG="$LIRCD_CONFIG --output=/run/lirc/lircd-$DEVICE"
|
||||||
|
LIRCD_CONFIG="$LIRCD_CONFIG --pidfile=/run/lirc/lircd-$DEVICE.pid"
|
||||||
|
LIRCD_CONFIG="$LIRCD_CONFIG --release=_LIRCUP"
|
||||||
|
|
||||||
LIRCD="/usr/sbin/lircd"
|
if [ -e "/storage/.config/lircd.conf" ]; then
|
||||||
LIRCD_CONFIG="--driver=$DRIVER --device=/dev/$DEVICE"
|
LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/lircd.conf"
|
||||||
LIRCD_CONFIG="$LIRCD_CONFIG --output=/run/lirc/lircd-$DEVICE"
|
elif [ -n "$CONFIG" ]; then
|
||||||
LIRCD_CONFIG="$LIRCD_CONFIG --pidfile=/run/lirc/lircd-$DEVICE.pid"
|
if [ -e "/storage/.config/$CONFIG" ]; then
|
||||||
LIRCD_CONFIG="$LIRCD_CONFIG --release=_LIRCUP"
|
LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/$CONFIG"
|
||||||
|
elif [ -e "/etc/lirc/$CONFIG" ]; then
|
||||||
|
LIRCD_CONFIG="$LIRCD_CONFIG /etc/lirc/$CONFIG"
|
||||||
|
else
|
||||||
|
echo "No device specific $CONFIG file found"
|
||||||
|
echo "You need to provide your own $CONFIG file"
|
||||||
|
echo "Place it in /storage/.config/$CONFIG"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No lircd.conf file found"
|
||||||
|
echo "You need to provide your own lircd.conf file"
|
||||||
|
echo "Place it in /storage/.config/lircd.conf"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -e "/storage/.config/lircd.conf" ]; then
|
# lircd daemonizes but lircd-uinput doesn't so we need to fork it to the background
|
||||||
LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/lircd.conf"
|
$LIRCD $LIRCD_CONFIG
|
||||||
elif [ -n "$CONFIG" ]; then
|
$LIRCD_UINPUT --release=_LIRCUP /run/lirc/lircd-$DEVICE &
|
||||||
if [ -e "/storage/.config/$CONFIG" ]; then
|
|
||||||
LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/$CONFIG"
|
|
||||||
elif [ -e "/etc/lirc/$CONFIG" ]; then
|
|
||||||
LIRCD_CONFIG="$LIRCD_CONFIG /etc/lirc/$CONFIG"
|
|
||||||
else
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec $LIRCD $LIRCD_CONFIG
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
remove)
|
|
||||||
if [ -e "/run/lirc/lircd-$DEVICE.pid" ]; then
|
|
||||||
PID=`cat /run/lirc/lircd-$DEVICE.pid`
|
|
||||||
if [ ! "x$PID" = "x" ]; then
|
|
||||||
kill $PID
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=lircd-uinput with %I
|
|
||||||
|
|
||||||
ConditionPathExists=/storage/.cache/services/lircd.conf
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/sbin/lircd-uinput --release=_LIRCUP /run/lirc/lircd-%I
|
|
||||||
Slice=system-lircd.slice
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=2
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
@ -6,11 +6,11 @@ Requires=lircd-defaults.service
|
|||||||
ConditionPathExists=/storage/.cache/services/lircd.conf
|
ConditionPathExists=/storage/.cache/services/lircd.conf
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=forking
|
||||||
ExecStart=/usr/lib/libreelec/lircd_helper add %I
|
ExecStart=/usr/lib/libreelec/lircd_helper %I
|
||||||
ExecStop=/usr/lib/libreelec/lircd_helper remove %I
|
|
||||||
TimeoutStopSec=1
|
TimeoutStopSec=1
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
@ -67,12 +67,6 @@ ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="add", \
|
|||||||
TAG+="systemd", ENV{SYSTEMD_WANTS}+="lircd@$name:$env{lircd_driver}:$env{lircd_conf}.service", \
|
TAG+="systemd", ENV{SYSTEMD_WANTS}+="lircd@$name:$env{lircd_driver}:$env{lircd_conf}.service", \
|
||||||
RUN+="lircd_wakeup_enable"
|
RUN+="lircd_wakeup_enable"
|
||||||
|
|
||||||
ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="add", \
|
|
||||||
TAG+="systemd", ENV{SYSTEMD_WANTS}+="lircd-uinput@$name.service"
|
|
||||||
|
|
||||||
ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="remove", \
|
|
||||||
RUN+="/usr/bin/systemctl stop lircd-uinput@$name.service"
|
|
||||||
|
|
||||||
ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="remove", \
|
ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="remove", \
|
||||||
RUN+="/usr/bin/systemctl stop lircd@$name:$env{lircd_driver}:$env{lircd_conf}.service"
|
RUN+="/usr/bin/systemctl stop lircd@$name:$env{lircd_driver}:$env{lircd_conf}.service"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user