Adds secret loading
This commit is contained in:
parent
cbf899eb40
commit
63fcd502a8
5 changed files with 81 additions and 30 deletions
36
.config/yadm/bootstrap.v2/applications/01-LoadSecrets.sh
Executable file
36
.config/yadm/bootstrap.v2/applications/01-LoadSecrets.sh
Executable file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
loadSecretsRepo() {
|
||||||
|
secretsGitPath="ssh://secrets-git-host/neintonine/yadm-config-secrets.git"
|
||||||
|
secretsFolderPath="$HOME/.local/share/secrets"
|
||||||
|
configFile="$HOME/.ssh/config"
|
||||||
|
|
||||||
|
if [[ -d "$secretsFolderPath/.git" ]]; then
|
||||||
|
(
|
||||||
|
cd "$secretsFolderPath"
|
||||||
|
git pull --ff-only
|
||||||
|
)
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$configFile" ]]; then
|
||||||
|
echo "Can't find the ssh config file!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep "Host secrets-git-host" "$configFile" >/dev/null; then
|
||||||
|
echo "Can't find secrets-git-host config"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git clone "$secretsGitPath" "$secretsFolderPath"
|
||||||
|
}
|
||||||
|
|
||||||
|
loadSecrets() {
|
||||||
|
secretsFolderPath="$HOME/.local/share/secrets"
|
||||||
|
|
||||||
|
loadSecretsRepo
|
||||||
|
"$secretsFolderPath/deploy.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
addActions loadSecrets
|
||||||
|
|
@ -26,6 +26,8 @@ declare -x -a actions
|
||||||
actions=()
|
actions=()
|
||||||
declare -x -a gitInstalls
|
declare -x -a gitInstalls
|
||||||
|
|
||||||
|
applications+=("")
|
||||||
|
|
||||||
addApplications ()
|
addApplications ()
|
||||||
{
|
{
|
||||||
for application in "$@"; do
|
for application in "$@"; do
|
||||||
|
|
@ -48,12 +50,15 @@ addGitInstall() {
|
||||||
gitInstalls+=("$name;$path;$setupCommand")
|
gitInstalls+=("$name;$path;$setupCommand")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ ! -z "$1" ]]; then
|
||||||
|
source "$APPLICATIONS_PATH/$1.sh"
|
||||||
|
else
|
||||||
while IFS= read -r file; do
|
while IFS= read -r file; do
|
||||||
if [[ -x "$file" && ! "$file" =~ "##" && ! "$file" =~ ~$ && ! "$file" =~ ".bak" ]]; then
|
if [[ -x "$file" && ! "$file" =~ "##" && ! "$file" =~ ~$ && ! "$file" =~ ".bak" ]]; then
|
||||||
source $file
|
source $file
|
||||||
fi
|
fi
|
||||||
done < <(find -L "$APPLICATIONS_PATH" -type f | sort)
|
done < <(find -L "$APPLICATIONS_PATH" -type f | sort)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo -n "# Installing/Updating applications (${#applications[@]})"
|
echo -n "# Installing/Updating applications (${#applications[@]})"
|
||||||
|
|
@ -109,5 +114,5 @@ echo "# Executing actions... (${#actions[@]})"
|
||||||
for action in "${actions[@]}";
|
for action in "${actions[@]}";
|
||||||
do
|
do
|
||||||
echo "==> Now executing: ${action}"
|
echo "==> Now executing: ${action}"
|
||||||
$action > /dev/null
|
$action
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/env sh
|
#!/bin/env sh
|
||||||
|
|
||||||
|
handleYadmSymlinks() {
|
||||||
foundSymlinks=false
|
foundSymlinks=false
|
||||||
|
|
||||||
for file in $(yadm diff --name-only --cached); do
|
for file in $(yadm diff --name-only --cached); do
|
||||||
|
|
@ -26,3 +27,6 @@ if [ $foundSymlinks ]; then
|
||||||
echo "Symlinks found. Adding .gitignore to commit..."
|
echo "Symlinks found. Adding .gitignore to commit..."
|
||||||
yadm add ~/.gitignore
|
yadm add ~/.gitignore
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
handleYadmSymlinks
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,12 @@ Host git.iedsoftworks.com
|
||||||
Port 2222
|
Port 2222
|
||||||
IdentityFile ~/.ssh/git.iedsoftworks.com.key
|
IdentityFile ~/.ssh/git.iedsoftworks.com.key
|
||||||
|
|
||||||
|
Host secrets-git-host
|
||||||
|
HostName git.iedsoftworks.com
|
||||||
|
User git
|
||||||
|
Port 2222
|
||||||
|
IdentityFile ~/.ssh/git.iedsoftworks.com.key
|
||||||
|
|
||||||
Host home
|
Host home
|
||||||
HostName home.server
|
HostName home.server
|
||||||
User michel
|
User michel
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue