5 # Required-Start: $local_fs $remote_fs
6 # Required-Stop: $local_fs $remote_fs
7 # Default-Start: 2 3 4 5
13 [ "$pid" != "" ] && kill $pid
16 read CMDLINE < /proc/cmdline
20 echo "Weston disabled"
30 # Weston for some reason dies if these environment variables are set
33 # This is all a nasty hack
34 if test -z "$XDG_RUNTIME_DIR"; then
35 export XDG_RUNTIME_DIR=/run/user/root
38 if [ ! -d "$XDG_RUNTIME_DIR" ] ; then
39 mkdir --parents $XDG_RUNTIME_DIR
40 chmod 0700 $XDG_RUNTIME_DIR
43 openvt -c 4 -f runWeston
45 # If there's no touchscreen device available, done
46 if [ ! -e /dev/input/touchscreen0 ] ; then
50 # If it was already calibrated, done
51 if [ -f "$WS_CALUDEV_FILE" ] ; then
55 # Check if SD card is mounted
56 mount | grep /run/media/mmcblk0p1 | grep vfat > /dev/null 2>&1
57 if [ "$?" = "0" ] ; then
63 # Check if SD card has a calibration rules file
64 SD_CALUDEV_FILE=/run/media/mmcblk0p1/ws-calibrate.rules
65 if [ "$SD_MOUNTED" = "1" -a -f "$SD_CALUDEV_FILE" ] ; then
66 # Copy it over to udev location
67 cp "$SD_CALUDEV_FILE" "$WS_CALUDEV_FILE"
69 # Run a calibration app and save output to udev rules
70 echo "Calibrating touchscreen (first time only)"
72 echo "*** To continue, please complete the touchscreen calibration"
73 echo -n "*** by touching the crosshairs on the LCD screen"
75 CAL_VALUES=`weston-calibrator|cut -c21-`
76 echo 'SUBSYSTEM=="input", ENV{WL_CALIBRATION}="'$CAL_VALUES'"' > $WS_CALUDEV_FILE
79 if [ "$SD_MOUNTED" = "1" ] ; then
80 cp "$WS_CALUDEV_FILE" "$SD_CALUDEV_FILE"
84 # Reload and re-run udev rules and restart weston
85 udevadm control --reload
89 openvt -c 4 -f runWeston
93 echo "Stopping Weston"
104 echo "usage: $0 { start | stop | restart }"