Skip to content

Instantly share code, notes, and snippets.

@GuillaumeFalourd
Created February 4, 2022 18:31
Show Gist options
  • Save GuillaumeFalourd/4efc73f1a6014b791c0ef223a023520a to your computer and use it in GitHub Desktop.
Save GuillaumeFalourd/4efc73f1a6014b791c0ef223a023520a to your computer and use it in GitHub Desktop.
Bash script to sign all files and subfiles located in the the same folder than the script.
#!/bin/bash
DEVELOPER_ID_APP=$1
export "DEVELOPER_ID_APP=$DEVELOPER_ID_APP"
signFile() {
filename=$1
echo "Signing FILE: $filename"
codesign -s "$DEVELOPER_ID_APP" -f --timestamp -i <ANY_BUNDLE_ID> -o runtime "$filename"
}
export -f signFile
find . -exec bash -c 'signFile "{}"' \;
@GuillaumeFalourd
Copy link
Author

Call the script by using sh codesign.sh $DEVELOPER_ID_APPLICATION

The Developer Id Application variable should look like this: Developer Id Application: <Name> (123456789)

@maxfornacon
Copy link

@GuillaumeFalourd why not make <ANY_BUNDLE_ID> a param of the script too?

@GuillaumeFalourd
Copy link
Author

@GuillaumeFalourd why not make <ANY_BUNDLE_ID> a param of the script too?

Could be done as well, it would probably look like this:

#!/bin/bash

DEVELOPER_ID_APP=$1
$BUNDLE_ID=$2
export "DEVELOPER_ID_APP=$DEVELOPER_ID_APP"
export "BUNDLE_ID=$BUNDLE_ID"

signFile() {
  filename=$1
  echo "Signing FILE: $filename"
  codesign -s "$DEVELOPER_ID_APP" -f --timestamp -i "$BUNDLE_ID" -o runtime "$filename"
}

export -f signFile
find . -exec bash -c 'signFile "{}"' \;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment