Support with parameters, please check the latest document

pull/1/head
liaronce 2021-10-08 13:55:25 +08:00
parent 5887e3ea83
commit 619cf4d5cd
4 changed files with 89 additions and 21 deletions

View File

@ -4,6 +4,18 @@ A shell script to add root certificates to Firefox OS
[Original README](README-original.md) [Original README](README-original.md)
## Usage
For Linux shell:
```bash
Usage: add-certificates-to-phone.sh [-r] (dir) | [-d] | [-h]
-r (dir) Enter the NSS DB root directory ( Such as Nokia, enter /data/b2g/mozilla )
Some phones may be different.
For more information, please visit: https://github.com/openGiraffes/b2g-certificates
-d Use default directory (/data/b2g/mozilla)
-h Output this help.
```
Linux (Debian & Ubuntu): Linux (Debian & Ubuntu):
```bash ```bash
@ -12,17 +24,23 @@ git clone https://github.com/openGiraffes/b2g-certificates
cd b2g-certificates cd b2g-certificates
chmod +x ./add-certificates-to-phone.sh chmod +x ./add-certificates-to-phone.sh
./add-certificates-to-phone.sh ./add-certificates-to-phone.sh -d # For Nokia user
# If you are using WSL, please run this (Need to add Android Platform Tools directory to PATH) # If you are using WSL, please run this (Need to add Android Platform Tools directory to PATH)
chmod +x ./add-certificates-to-phone-wsl.sh chmod +x ./add-certificates-to-phone-wsl.sh
./add-certificates-to-phone-wsl.sh ./add-certificates-to-phone-wsl.sh -d # For Nokia user
``` ```
Windows Batch(Need to add Android Platform Tools directory to PATH): Windows Batch(Need to add Android Platform Tools directory to PATH):
```batch ```
add-certificates-to-phone.bat add-certificates-to-phone.bat
Enter the NSS DB root directory ( Such as Nokia, enter /data/b2g/mozilla )
Some phones may be different.
For more information, please visit: https://github.com/openGiraffes/b2g-certificates
(Enter the path here)
``` ```
NSS certutil compiled by myself. NSS certutil compiled by myself.

View File

@ -1,7 +1,35 @@
#!/bin/bash #!/bin/bash
function log
{
GREEN="\E[32m"
RESET="\033[00;00m"
echo -e "${GREEN}$1${RESET}"
}
usage() {
echo "Usage: ${0} [-r] (dir) | [-d] | [-h]" 1>&2
echo ""
echo "-r (dir) Enter the NSS DB root directory ( Such as Nokia, enter /data/b2g/mozilla )"
echo " Some phones may be different."
echo " For more information, please visit: https://github.com/openGiraffes/b2g-certificates"
echo "-d Use default directory (/data/b2g/mozilla)"
echo "-h Output this help."
exit 1
}
ROOT_DIR_DB=
while getopts "dhr:" options
do
case ${options} in
d) ROOT_DIR_DB=/data/b2g/mozilla;;
r) ROOT_DIR_DB=$OPTARG;;
h) usage;;
esac
done
CERT_DIR=certs CERT_DIR=certs
ROOT_DIR_DB=/data/b2g/mozilla
CERT=cert9.db CERT=cert9.db
KEY=key4.db KEY=key4.db
PKCS11=pkcs11.txt PKCS11=pkcs11.txt
@ -13,13 +41,6 @@ least once before running this script."
exit 1 exit 1
fi fi
function log
{
GREEN="\E[32m"
RESET="\033[00;00m"
echo -e "${GREEN}$1${RESET}"
}
# cleanup # cleanup
rm -f ./$CERT rm -f ./$CERT
rm -f ./$KEY rm -f ./$KEY

View File

@ -1,13 +1,21 @@
@echo off @echo off
:: Set environment variable :: Set environment variable
@echo Enter the NSS DB root directory ( Such as Nokia, enter /data/b2g/mozilla )
@echo Some phones may be different.
@echo For more information, please visit: https://github.com/openGiraffes/b2g-certificates
@echo:
set /p ROOT_DIR_DB=
set CERT_DIR=certs set CERT_DIR=certs
set TEMP=tmp set TEMP=tmp
set CERT=cert9.db set CERT=cert9.db
set KEY=key4.db set KEY=key4.db
set PKCS11=pkcs11.txt set PKCS11=pkcs11.txt
for /f %%i in ('adb shell "ls -d /data/b2g/mozilla/*.default 2>/dev/null" ^|^| "bin/sed.exe" "s/default.*$/default/g"') do set DB_DIR=%%i for /f %%i in ('adb shell "ls -d %ROOT_DIR_DB%/*.default 2>/dev/null" ^|^| "bin/sed.exe" "s/default.*$/default/g"') do set DB_DIR=%%i
@echo %DB_DIR%
if DB_DIR == "" ( if DB_DIR == "" (
@echo:
echo "Profile directory does not exists. Please start the b2g process at least once before running this script." echo "Profile directory does not exists. Please start the b2g process at least once before running this script."
pause pause
) )
@ -30,7 +38,7 @@ adb pull %DB_DIR%/%PKCS11% ./%TEMP%/
@echo Set password (hit enter twice to set an empty password) @echo Set password (hit enter twice to set an empty password)
"bin/nss/certutil.exe" -d %TEMP% -N "bin/nss/certutil.exe" -d %TEMP% -N
@echo Adding certificats @echo Adding certificates
for %%i in (%CERT_DIR%/*) do ( for %%i in (%CERT_DIR%/*) do (
echo Adding certificate %%i echo Adding certificate %%i
"bin/nss/certutil.exe" -d %TEMP% -A -n "`basename %%i`" -t "C,C,TC" -i %CERT_DIR%/%%i "bin/nss/certutil.exe" -d %TEMP% -A -n "`basename %%i`" -t "C,C,TC" -i %CERT_DIR%/%%i

View File

@ -1,7 +1,35 @@
#!/bin/bash #!/bin/bash
function log
{
GREEN="\E[32m"
RESET="\033[00;00m"
echo -e "${GREEN}$1${RESET}"
}
usage() {
echo "Usage: ${0} [-r] (dir) | [-d] | [-h]" 1>&2
echo ""
echo "-r (dir) Enter the NSS DB root directory ( Such as Nokia, enter /data/b2g/mozilla )"
echo " Some phones may be different."
echo " For more information, please visit: https://github.com/openGiraffes/b2g-certificates"
echo "-d Use default directory (/data/b2g/mozilla)"
echo "-h Output this help."
exit 1
}
ROOT_DIR_DB=
while getopts "dhr:" options
do
case ${options} in
d) ROOT_DIR_DB=/data/b2g/mozilla;;
r) ROOT_DIR_DB=$OPTARG;;
h) usage;;
esac
done
CERT_DIR=certs CERT_DIR=certs
ROOT_DIR_DB=/data/b2g/mozilla
CERT=cert9.db CERT=cert9.db
KEY=key4.db KEY=key4.db
PKCS11=pkcs11.txt PKCS11=pkcs11.txt
@ -13,13 +41,6 @@ least once before running this script."
exit 1 exit 1
fi fi
function log
{
GREEN="\E[32m"
RESET="\033[00;00m"
echo -e "${GREEN}$1${RESET}"
}
# cleanup # cleanup
rm -f ./$CERT rm -f ./$CERT
rm -f ./$KEY rm -f ./$KEY