fix problematic echos
This commit is contained in:
@@ -28,17 +28,15 @@ let
|
||||
in
|
||||
pkgs.runCommandLocal name { meta.mainProgram = name; } ''
|
||||
mkdir -p "$out"/bin
|
||||
echo ${lib.escapeShellArg binContents} > "$out"/bin/${name}
|
||||
printf '%s' ${lib.escapeShellArg binContents} > "$out"/bin/${name}
|
||||
chmod a+x "$out"/bin/${name}
|
||||
out_base="$(dirname "$out")"
|
||||
LC_ALL=C
|
||||
completion_function_name="_completion_''${out_base//[^a-zA-Z0-9_]/_}"
|
||||
completion_file="$out"/share/bash-completion/completions/${name}
|
||||
mkdir -p "$(dirname "$completion_file")"
|
||||
echo "''${completion_function_name}() {" >> "$completion_file"
|
||||
echo ${lib.escapeShellArg funcContents} >> "$completion_file"
|
||||
echo "}" >> "$completion_file"
|
||||
echo "complete -F $completion_function_name ${name}" >> "$completion_file"
|
||||
mkdir -p "$(dirname -- "$completion_file")"
|
||||
printf '%s() {\n%s\n}\n' "$completion_function_name" ${lib.escapeShellArg funcContents} > "$completion_file"
|
||||
printf 'complete -F %q %q\n' "$completion_function_name" ${lib.escapeShellArg name} >> "$completion_file
|
||||
'';
|
||||
ms_text = with_sudo: ''
|
||||
svl_minmax_args $# 1 3
|
||||
@@ -75,7 +73,7 @@ in
|
||||
'')
|
||||
(script "copy-altcaps" ''
|
||||
result="$(altcaps "$@")"
|
||||
echo -n "$result" | wl-copy
|
||||
printf '%s' "$result" | wl-copy
|
||||
echo "Copied to clipboard: $result"
|
||||
'')
|
||||
(script "nr" ''
|
||||
@@ -163,7 +161,7 @@ in
|
||||
if [[ "$pointed" == /nix/var/nix/profiles/system-* ]]; then
|
||||
continue
|
||||
fi
|
||||
echo "$pointed"
|
||||
printf '%s' "$pointed"
|
||||
done
|
||||
'')
|
||||
];
|
||||
|
@@ -12,7 +12,7 @@ let
|
||||
sshPubText:
|
||||
vaculib.outputOf {
|
||||
name = "age-from-ssh.txt";
|
||||
cmd = ''echo ${lib.escapeShellArg sshPubText} | ${ssh-to-age} > "$out"'';
|
||||
cmd = ''printf '%s' ${lib.escapeShellArg sshPubText} | ${ssh-to-age} > "$out"'';
|
||||
};
|
||||
userKeys = lib.attrValues config.vacu.ssh.authorizedKeys;
|
||||
userKeysAge = map sshToAge userKeys;
|
||||
@@ -26,7 +26,7 @@ let
|
||||
testAgeSecret = "AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQPQQ94XCHF";
|
||||
testAgePublic = vaculib.outputOf {
|
||||
name = "test-age-public-key.txt";
|
||||
cmd = ''echo ${lib.escapeShellArg testAgeSecret} | ${pkgs.age}/bin/age-keygen -y > "$out"'';
|
||||
cmd = ''printf '%s' ${lib.escapeShellArg testAgeSecret} | ${pkgs.age}/bin/age-keygen -y > "$out"'';
|
||||
};
|
||||
sopsConfig = {
|
||||
creation_rules = [
|
||||
|
@@ -40,7 +40,7 @@ let
|
||||
cp {definitions,elements}.units "$out"
|
||||
ln -s ${../units/currency.units} "$out"/currency.units
|
||||
ln -s ${../units/cpi.units} "$out"/cpi.units
|
||||
echo ${lib.escapeShellArg config.vacu.units.lines} > "$out"/vacu.units
|
||||
printf '%s' ${lib.escapeShellArg config.vacu.units.lines} > "$out"/vacu.units
|
||||
'';
|
||||
};
|
||||
in
|
||||
@@ -104,8 +104,8 @@ in
|
||||
#
|
||||
|
||||
output="$(${lib.getExe config.vacu.units.finalPackage} --check)"
|
||||
echo "$output"
|
||||
filteredLines="$(echo "$output" \
|
||||
printf '%s' "$output"
|
||||
filteredLines="$(printf '%s' "$output" \
|
||||
| grep -v '^\s*$' \
|
||||
| grep -v 'Currency exchange rates from' \
|
||||
| grep -v 'Consumer price index data from' \
|
||||
|
@@ -34,7 +34,7 @@ let
|
||||
keySizeHex = builtins.toString (keySizeBits / 4);
|
||||
in
|
||||
pkgs.runCommand "deterministic-privkey-${name}.pem" { } ''
|
||||
seed=$(echo ${lib.escapeShellArg (builtins.toJSON name)} | ${pkgs.ruby_3_2}/bin/ruby -rjson -e 'name = JSON.parse(STDIN.gets); print name.unpack("H*")[0].ljust(${keySizeHex}, "0")')
|
||||
seed=$(printf '%s' ${lib.escapeShellArg (builtins.toJSON name)} | ${pkgs.ruby_3_2}/bin/ruby -rjson -e 'name = JSON.parse(STDIN.gets); print name.unpack("H*")[0].ljust(${keySizeHex}, "0")')
|
||||
${pkgs.gnutls}/bin/certtool --generate-privkey --outfile="$out" --key-type=rsa --sec-param=high --seed=$seed
|
||||
'';
|
||||
generateCert =
|
||||
|
@@ -23,8 +23,8 @@ else
|
||||
fi
|
||||
|
||||
svl_eprintln() {
|
||||
echo -n "$@" >&2
|
||||
echo
|
||||
printf '%s' "$@" >&2
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
_shellvaculib_debug_enabled() {
|
||||
|
@@ -14,7 +14,7 @@ in
|
||||
fi
|
||||
${pkgs.coreutils}/bin/stty -F ${serialNode} 38400 raw -echoe -echok -echoctl -echoke
|
||||
for i in 1..5; do
|
||||
echo -e -n 'set_speed 10\r' > ${serialNode}
|
||||
printf 'set_speed 10\r' > ${serialNode}
|
||||
sleep 1
|
||||
done
|
||||
'';
|
||||
|
@@ -46,7 +46,7 @@ writers.writeBashBin "update-git-keys" ''
|
||||
# declare -p curl_common
|
||||
echo GET "$url_keys"
|
||||
resp="$("''${curl_common[@]}" "$url_keys")"
|
||||
for url in $(echo "$resp" | jq .[].url -r); do
|
||||
for url in $(printf '%s' "$resp" | jq .[].url -r); do
|
||||
echo DELETE "$url"
|
||||
"''${curl_common[@]}" "$url" -X DELETE
|
||||
done
|
||||
|
@@ -69,7 +69,7 @@ let
|
||||
);
|
||||
sopsTestSecretsFolder = pkgs.runCommand "test-secrets-encrypted" { } ''
|
||||
mkdir -p "$out"/liam
|
||||
SOPS_AGE_KEY=${lib.escapeShellArg testAgeSecret} ${pkgs.sops}/bin/sops --verbose -e --age "$(echo ${lib.escapeShellArg testAgeSecret} | ${pkgs.age}/bin/age-keygen -y)" ${lib.escapeShellArg sopsTestSecretsYaml} --output-type yaml > "$out"/liam/main.yaml
|
||||
SOPS_AGE_KEY=${lib.escapeShellArg testAgeSecret} ${pkgs.sops}/bin/sops --verbose -e --age "$(printf '%s' ${lib.escapeShellArg testAgeSecret} | ${pkgs.age}/bin/age-keygen -y)" ${lib.escapeShellArg sopsTestSecretsYaml} --output-type yaml > "$out"/liam/main.yaml
|
||||
'';
|
||||
mailtestModule =
|
||||
{
|
||||
@@ -228,26 +228,6 @@ in
|
||||
let
|
||||
borgCfg = nodes.liam.vacu.liam.backup;
|
||||
user = borgCfg.rsyncUser;
|
||||
loginCommand = pkgs.writers.writeBashBin "special-rsync-login" { } ''
|
||||
set -euo pipefail
|
||||
if [ -n "$SSH_ORIGINAL_COMMAND" ]; then
|
||||
echo "hi there"
|
||||
while read; do echo; done
|
||||
echo "goodbye"
|
||||
exit 0
|
||||
fi
|
||||
original_command=($SSH_ORIGINAL_COMMAND)
|
||||
command="''${original_command[0]}"
|
||||
args="''${original_command[@]:1}"
|
||||
case "$command" in
|
||||
borg14)
|
||||
exec ${lib.getExe pkgs.borgbackup} "''${args[@]}"
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
'';
|
||||
in
|
||||
{
|
||||
users.users.${user} = {
|
||||
|
@@ -40,7 +40,7 @@ liam.succeed("systemctl start auto-borg-gen-key.service")
|
||||
liam_autoborger_key = liam.succeed("cat /var/lib/auto-borg/id_ed25519.pub").strip()
|
||||
rsyncnet.succeed("install -d --owner=fm2382 --mode=0700 /home/fm2382/.ssh")
|
||||
rsyncnet.succeed(
|
||||
f"install --owner=fm2382 --mode=0600 -T <(echo 'command=\"borg14 serve --restrict-to-repository /home/fm2382/borg-repos/liam-backup --append-only\",restrict {liam_autoborger_key}') /home/fm2382/.ssh/authorized_keys"
|
||||
f"install --owner=fm2382 --mode=0600 -T <(printf '%s' 'command=\"borg14 serve --restrict-to-repository /home/fm2382/borg-repos/liam-backup --append-only\",restrict {liam_autoborger_key}') /home/fm2382/.ssh/authorized_keys"
|
||||
)
|
||||
rsyncnet.succeed("sudo -u fm2382 borg-init")
|
||||
liam.succeed("systemctl start auto-borg.service")
|
||||
|
Reference in New Issue
Block a user