Pkg // Update pre/post install scripts.

This commit is contained in:
ShikiSuen 2022-04-06 12:17:47 +08:00
parent 19193abe58
commit bf199ce5f7
2 changed files with 11 additions and 10 deletions

View File

@ -1,18 +1,20 @@
#!/bin/sh
loggedInUser=$(stat -f%Su /dev/console)
TARGET='vChewing'
login_user=`/usr/bin/stat -f%Su /dev/console`
# First, copy the wrongfully installed contents to the right location:
cp -r /Library/Input\ Methods/vChewing.app /Users/$(stat -f%Su /dev/console)/Library/Input\ Methods/ || true
cp -r /Library/Keyboard\ Layouts/vChewing* /Users/$(stat -f%Su /dev/console)/Library/Keyboard\ Layouts/ || true
chown "$loggedInUser" /Users/$(stat -f%Su /dev/console)/Library/Input\ Methods/vChewing.app || true
chown "$loggedInUser" /Users/$(stat -f%Su /dev/console)/Library/Keyboard\ Layouts/vChewing* || true
cp -r /Library/Input\ Methods/"${TARGET}".app /Users/"${login_user}"/Library/Input\ Methods/ || true
cp -r /Library/Keyboard\ Layouts/"${TARGET}"* /Users/"${login_user}"/Library/Keyboard\ Layouts/ || true
chown "${login_user}" /Users/"${login_user}"/Library/Input\ Methods/"${TARGET}".app || true
chown "${login_user}" /Users/"${login_user}"/Library/Keyboard\ Layouts/"${TARGET}"* || true
sleep 1
# Second, clean the wrongfully installed contents:
rm -rf /Library/Input\ Methods/vChewing.app || true
rm -rf /Library/Keyboard\ Layouts/vChewing* || true
rm -rf /Library/Input\ Methods/"${TARGET}".app || true
rm -rf /Library/Keyboard\ Layouts/"${TARGET}"* || true
sleep 1
# Finally, register the input method:
/Users/$(stat -f%Su /dev/console)/Library/Input\ Methods/vChewing.app/Contents/MacOS/vChewing install --all || true
/Users/"${login_user}"/Library/Input\ Methods/"${TARGET}".app/Contents/MacOS/"${TARGET}" install --all || true

View File

@ -1,9 +1,8 @@
#!/bin/sh
loggedInUser=$(stat -f%Su /dev/console)
killall vChewing || true
if [ "$loggedInUser" = root ]; then
if [ "${login_user}" = root ]; then
rm -rf /Library/Input\ Methods/vChewing.app || true
rm -rf /Library/Keyboard\ Layouts/vChewingKeyLayout.bundle || true
rm -rf /Library/Keyboard\ Layouts/vChewing\ Dachen.keylayout || true