contrib/windows/sbm-setup (1446 bytes)
1 #!/bin/sh 2 3 # sbm-setup: tasks of the Windows installer. 4 # 5 # sbm-setup data give the user the example tags and search keywords, 6 # and keep the files that the user has 7 # sbm-setup stop stop the bm-watch that the installer started 8 9 # The installer starts this script with the PATH of Windows. That PATH does 10 # not have the Cygwin tools, for example tr, mkdir and cp. 11 PATH=/usr/bin:$PATH 12 13 case ${1-} in 14 data) 15 d=${XDG_DATA_HOME:-$HOME/.local/share}/sbm 16 mkdir -p "$d" 17 for f in engines usertags; do 18 [ -e "$d/$f" ] || cp "/usr/local/share/sbm/$f" "$d/" 19 done 20 ;; 21 stop) 22 # The hidden mintty of bm-watch has the class sbm-watch. When it 23 # stops, bm-watch gets SIGHUP and stops too. Cygwin shows the 24 # arguments of a process in /proc/PID/cmdline. A process can stop 25 # during the loop, for example bm-watch after its mintty. Then the 26 # shell cannot open its file: 2>/dev/null comes first, so the shell 27 # writes that error to /dev/null. 28 for f in /proc/[0-9]*/cmdline; do 29 case $(tr '\0' ' ' 2>/dev/null < "$f") in 30 *'--class sbm-watch '*) 31 pid=${f#/proc/} 32 kill "${pid%/cmdline}" 2>/dev/null 33 ;; 34 esac 35 done 36 ;; 37 *) 38 printf 'usage: sbm-setup data | stop\n' >&2 39 exit 2 40 ;; 41 esac