Last active
April 11, 2024 03:40
-
-
Save Superbil/ea122a825dee556657a9a798aa3cd53f to your computer and use it in GitHub Desktop.
HiPKILocalSignServer macOS 1.3.4.7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## Use sudo to run this script | |
rm -rf ~/Library/HiPKILocalSignServer/ | |
rm -rf ~/Lib/libHicos_p11v1.dylib | |
rm -rf ~/bin/checkHIPKILocalServer.sh | |
rm -rf ~/bin/stopHIPKILocalServer.sh | |
rm -rf ~/bin/runHIPKILocalServer.sh | |
rm -rf /Applications/HiPKILocalSignServer.app | |
pkgutil --forget com.node.HiPKILocalSignServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#(0) | |
# if ~/Library/HiPKILocalSignServer exist, delete it first to make sure a clean install | |
if [ -d ~/Library/HiPKILocalSignServer ] | |
then | |
#the folder already exist | |
sudo rm -rf ~/Library/HiPKILocalSignServer/* | |
fi | |
# delete the files in /usr/local/bin and /usr/local/lib (old versions installed here) | |
usrlocalbin_path=/usr/local/bin | |
usrlocallib_path=/usr/local/lib | |
rm -f $usrlocalbin_path/checkHIPKILocalServer.sh | |
rm -f $usrlocalbin_path/stopHIPKILocalServer.sh | |
rm -f $usrlocalbin_path/runHIPKILocalServer.sh | |
rm -f $usrlocallib_path/libHicos_p11v1.dylib | |
#(1)===unzip file=== | |
unzip HiPKILocalSignServer_install.zip | |
installDir=./HiPKILocalSignServer_install | |
# make this folder for install log to write and set its ownership to user(so that the log can be written) | |
mkdir ~/Library/HiPKILocalSignServer | |
mydir=~/Library/HiPKILocalSignServer/ | |
sudo chown $USER:$(id -gn $USER) ~/Library/HiPKILocalSignServer | |
# new the file that stores install log and set its ownership to user | |
touch $mydir/log.HIPKILocalServer.install.txt | |
sudo chown $USER:$(id -gn $USER) $mydir/log.HIPKILocalServer.install.txt | |
#(2)===write some user info(os version and install date)=== | |
echo "===user install started===" >> $mydir/log.HIPKILocalServer.install.txt | |
date >> $mydir/log.HIPKILocalServer.install.txt | |
sw_vers >> $mydir/log.HIPKILocalServer.install.txt | |
#(3)===copy files=== | |
# copy HiPKILocalSignServer common folder to ~/Library | |
cp -R $installDir/HiPKILocalSignServer_common/ ~/Library/HiPKILocalSignServer/ >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
#=====detect language===== | |
#root user(sudo) cannot get defaults read .GlobalPreferences, so using "su - $USER -c" instead | |
sys_lang=$(su - $USER -c 'echo $(defaults read .GlobalPreferences AppleLanguages | tr -d [:space:] | cut -c3-4)') >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
if [ "$sys_lang" = "en" ] ; then | |
cp -R $installDir/HiPKILocalSignServer_en/ ~/Library/HiPKILocalSignServer/ >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
else | |
cp -R $installDir/HiPKILocalSignServer_zhTW/ ~/Library/HiPKILocalSignServer/ >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
fi | |
sudo mkdir -p ~/lib >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
sudo mkdir -p ~/bin >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
# copy pkcs11 lib to /usr/local/lib | |
cp $installDir/libHicos_p11v1.dylib ~/lib >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
# copy plist to user LaunchAgents | |
cp $installDir/com.node.HIPKILocalServer.cht.plist ~/Library/LaunchAgents >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
# copy run,stop,check script to ~/bin (called by app) | |
cp $installDir/checkHIPKILocalServer.sh ~/bin >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
cp $installDir/stopHIPKILocalServer.sh ~/bin >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
cp $installDir/runHIPKILocalServer.sh ~/bin >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
# copy app to /Applications | |
cp -R $installDir/HiPKILocalSignServer.app /Applications >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
#(4)===change the permission of plist to the current user=== | |
sudo chown $USER:$(id -gn $USER) ~/Library/LaunchAgents/com.node.HIPKILocalServer.cht.plist >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
#(5)===launch the plist=== | |
# unload it first in case it's running | |
su - $USER -c 'launchctl unload ~/Library/LaunchAgents/com.node.HIPKILocalServer.cht.plist' >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
su - $USER -c 'launchctl load ~/Library/LaunchAgents/com.node.HIPKILocalServer.cht.plist' >> $mydir/log.HIPKILocalServer.install.txt 2>&1 | |
#(6)===open the application=== | |
open -n /Applications/HiPKILocalSignServer.app >> $mydir/log.HIPKILocalServer.install.txt 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment