Merge pull request #1305 from lrusak/lirc-libreelec-8.0

backport of #1295 (lirc: simplify scripts)
This commit is contained in:
Christian Hewitt 2017-02-09 06:28:25 +04:00 committed by GitHub
commit 8f6f8614fe
4 changed files with 38 additions and 65 deletions

View File

@ -17,22 +17,18 @@
# 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
add)
if [ "x$DRIVER" = "x" ]; then if [ "x$DRIVER" = "x" ]; then
exit 1; exit 1;
fi fi
mkdir -p '/run/lirc' mkdir -p '/run/lirc'
if [ ! -e "/run/lirc/lircd-$DEVICE.pid" ]; then
LIRCD="/usr/sbin/lircd" LIRCD="/usr/sbin/lircd"
LIRCD_UINPUT="/usr/sbin/lircd-uinput"
LIRCD_CONFIG="--driver=$DRIVER --device=/dev/$DEVICE" LIRCD_CONFIG="--driver=$DRIVER --device=/dev/$DEVICE"
LIRCD_CONFIG="$LIRCD_CONFIG --output=/run/lirc/lircd-$DEVICE" LIRCD_CONFIG="$LIRCD_CONFIG --output=/run/lirc/lircd-$DEVICE"
LIRCD_CONFIG="$LIRCD_CONFIG --pidfile=/run/lirc/lircd-$DEVICE.pid" LIRCD_CONFIG="$LIRCD_CONFIG --pidfile=/run/lirc/lircd-$DEVICE.pid"
@ -46,23 +42,20 @@ case "$ACTION" in
elif [ -e "/etc/lirc/$CONFIG" ]; then elif [ -e "/etc/lirc/$CONFIG" ]; then
LIRCD_CONFIG="$LIRCD_CONFIG /etc/lirc/$CONFIG" LIRCD_CONFIG="$LIRCD_CONFIG /etc/lirc/$CONFIG"
else 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 exit 0
fi fi
else 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 exit 0
fi fi
exec $LIRCD $LIRCD_CONFIG # lircd daemonizes but lircd-uinput doesn't so we need to fork it to the background
fi $LIRCD $LIRCD_CONFIG
;; $LIRCD_UINPUT --release=_LIRCUP /run/lirc/lircd-$DEVICE &
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

View File

@ -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

View File

@ -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

View File

@ -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"