Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自動インストール設定の追加 #80

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
17 changes: 17 additions & 0 deletions etc/rtmouse.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=rtmouse driver
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
Restart=no
ExecStart=/etc/init.d/rtmouse.sh start
ExecReload=/etc/init.d/rtmouse.sh restart
ExecStopt=/etc/init.d/rtmouse.sh stop
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rtmouse

[Install]
WantedBy=multi-user.target
73 changes: 73 additions & 0 deletions etc/rtmouse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
#
#
### BEGIN INIT INFO
# Provides: rtmouse
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: RasPiMouse_Driver
# Description: Rasoberry Pi Mouse Driver by RT Corporation
### END INIT INFO

SCRIPTNAME=rtmouse.sh
PROC_FILE=/proc/modules
GREP=/bin/grep
MODPROBE=/sbin/modprobe
MODULE_NAME=rtmouse
DEP_MODULE_NAME=mcp320x

[ -f $PROC_FILE ] || exit 0
[ -x $GREP ] || exit 0
[ -x $MODPROBE ] || exit 0

RES=`$GREP $MODULE_NAME $PROC_FILE`

# installing rtmouse.ko
install_rtmouse()
{
if [ "$RES" = "" ]; then
$MODPROBE $MODULE_NAME
echo "Module Install $MODULE_NAME"
else
echo "Module '$MODULE_NAME' is already installed"
fi
}

# uninstalling rtmouse.ko
remove_rtmouse()
{
if [ "$RES" = "" ]; then
echo "Module '$MODULE_NAME' isn't installed yet."
else
$MODPROBE -r $MODULE_NAME
$MODPROBE -r $DEP_MODULE_NAME
echo "Module '$MODULE_NAME' is rmoved."
fi
}

case "$1" in
start)
install_rtmouse
sleep 1
/bin/chmod a+rw /dev/rt*
;;
stop)
remove_rtmouse
;;
status)
if [ "$RES" = "" ]; then
echo "Module '$MODULE_NAME' isn't installed yet."
exit 0
else
echo "Module '$MODULE_NAME' is already installed"
exit 0
fi
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
exit 3
esac

exit 0
14 changes: 12 additions & 2 deletions src/drivers/Makefile.header_from_apt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ clean:
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean

install: rtmouse.ko
cp ../../50-rtmouse.rules /etc/udev/rules.d/
cp rtmouse.ko /lib/modules/$(shell uname -r)/kernel/drivers/
cp ../../etc/50-rtmouse.rules /etc/udev/rules.d/
cp ../../etc/rtmouse.sh /etc/init.d/
chmod 755 /etc/init.d/rtmouse.sh
cp ../../etc/rtmouse.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable rtmouse.service

uninstall:
rm /etc/udev/rules.d/50-rtmouse.rules
-systemctl stop rtmouse.service
systemctl disable rtmouse.service
rm /etc/init.d/rtmouse.sh
rm /etc/systemd/system/rtmouse.sh

#Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
#Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
20 changes: 19 additions & 1 deletion src/drivers/Makefile.header_from_source
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,22 @@ rtmouse.ko: rtmouse.c
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules

clean:
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean

install: rtmouse.ko
cp rtmouse.ko /lib/modules/$(shell uname -r)/kernel/drivers/
cp ../../etc/50-rtmouse.rules /etc/udev/rules.d/
cp ../../etc/rtmouse.sh /etc/init.d/
chmod 755 /etc/init.d/rtmouse.sh
cp ../../etc/rtmouse.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable rtmouse.service

uninstall:
rm /etc/udev/rules.d/50-rtmouse.rules
-systemctl stop rtmouse.service
systemctl disable rtmouse.service
rm /etc/init.d/rtmouse.sh
rm /etc/systemd/system/rtmouse.sh

#Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
Loading