File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,13 @@ Each entry uses the format:
2424- ** api:** Fetches from a private GitHub repo using the GitHub API (requires ` GITHUB_TOKEN ` environment variable).
2525- ** ghuser:** Fetches public keys from a GitHub user's profile (provide the GitHub username after the colon).
2626
27+ You can also set your GitHub token in the config file using ` CONF_GITHUB_TOKEN ` .
28+ If ` GITHUB_TOKEN ` is not set in the environment, the script will use ` CONF_GITHUB_TOKEN ` from ` users.conf ` .
29+
2730** Example ` users.conf ` :**
2831``` bash
32+ CONF_GITHUB_TOKEN=" your_github_token_here"
33+
2934declare -A USER_KEYS=(
3035 [" ubuntu" ]=" raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
3136 [" devuser" ]=" api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
@@ -36,7 +41,7 @@ declare -A USER_KEYS=(
3641## Usage
3742
38431 . Edit the ` users.conf ` file to define users and their key URLs or GitHub usernames.
39- 2 . If using the ` api ` method, export your GitHub token:
44+ 2 . If using the ` api ` method, either export your GitHub token or set ` CONF_GITHUB_TOKEN ` in ` users.conf ` :
4045 ``` bash
4146 export GITHUB_TOKEN=your_token_here
4247 ```
Original file line number Diff line number Diff line change 22set -euo pipefail
33
44# shellcheck disable=SC2034 # planned to be used in a future release
5- SCRIPT_VERSION=" 0.0.6 "
5+ SCRIPT_VERSION=" 0.0.7 "
66
77# === Load user configuration ===
88SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
@@ -15,6 +15,11 @@ if ! source "$SCRIPT_DIR/users.conf"; then
1515 exit 1
1616fi
1717
18+ # Load GITHUB_TOKEN from config if set and not already in environment
19+ if [[ -n " ${CONF_GITHUB_TOKEN:- } " && -z " ${GITHUB_TOKEN:- } " ]]; then
20+ export GITHUB_TOKEN=" $CONF_GITHUB_TOKEN "
21+ fi
22+
1823log_message () {
1924 local TIMESTAMP
2025 TIMESTAMP=" $( date ' +%Y-%m-%d %H:%M:%S' ) "
Original file line number Diff line number Diff line change 1+
2+ CONF_GITHUB_TOKEN="your_github_token_here"
3+
14declare -A USER_KEYS=(
25 ["ubuntu"]="raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
36 ["devuser"]="api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
You can’t perform that action at this time.
0 commit comments