fix problematic echos
This commit is contained in:
@@ -28,17 +28,15 @@ let
|
|||||||
in
|
in
|
||||||
pkgs.runCommandLocal name { meta.mainProgram = name; } ''
|
pkgs.runCommandLocal name { meta.mainProgram = name; } ''
|
||||||
mkdir -p "$out"/bin
|
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}
|
chmod a+x "$out"/bin/${name}
|
||||||
out_base="$(dirname "$out")"
|
out_base="$(dirname "$out")"
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
completion_function_name="_completion_''${out_base//[^a-zA-Z0-9_]/_}"
|
completion_function_name="_completion_''${out_base//[^a-zA-Z0-9_]/_}"
|
||||||
completion_file="$out"/share/bash-completion/completions/${name}
|
completion_file="$out"/share/bash-completion/completions/${name}
|
||||||
mkdir -p "$(dirname "$completion_file")"
|
mkdir -p "$(dirname -- "$completion_file")"
|
||||||
echo "''${completion_function_name}() {" >> "$completion_file"
|
printf '%s() {\n%s\n}\n' "$completion_function_name" ${lib.escapeShellArg funcContents} > "$completion_file"
|
||||||
echo ${lib.escapeShellArg funcContents} >> "$completion_file"
|
printf 'complete -F %q %q\n' "$completion_function_name" ${lib.escapeShellArg name} >> "$completion_file
|
||||||
echo "}" >> "$completion_file"
|
|
||||||
echo "complete -F $completion_function_name ${name}" >> "$completion_file"
|
|
||||||
'';
|
'';
|
||||||
ms_text = with_sudo: ''
|
ms_text = with_sudo: ''
|
||||||
svl_minmax_args $# 1 3
|
svl_minmax_args $# 1 3
|
||||||
@@ -75,7 +73,7 @@ in
|
|||||||
'')
|
'')
|
||||||
(script "copy-altcaps" ''
|
(script "copy-altcaps" ''
|
||||||
result="$(altcaps "$@")"
|
result="$(altcaps "$@")"
|
||||||
echo -n "$result" | wl-copy
|
printf '%s' "$result" | wl-copy
|
||||||
echo "Copied to clipboard: $result"
|
echo "Copied to clipboard: $result"
|
||||||
'')
|
'')
|
||||||
(script "nr" ''
|
(script "nr" ''
|
||||||
@@ -163,7 +161,7 @@ in
|
|||||||
if [[ "$pointed" == /nix/var/nix/profiles/system-* ]]; then
|
if [[ "$pointed" == /nix/var/nix/profiles/system-* ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "$pointed"
|
printf '%s' "$pointed"
|
||||||
done
|
done
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
|
@@ -12,7 +12,7 @@ let
|
|||||||
sshPubText:
|
sshPubText:
|
||||||
vaculib.outputOf {
|
vaculib.outputOf {
|
||||||
name = "age-from-ssh.txt";
|
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;
|
userKeys = lib.attrValues config.vacu.ssh.authorizedKeys;
|
||||||
userKeysAge = map sshToAge userKeys;
|
userKeysAge = map sshToAge userKeys;
|
||||||
@@ -26,7 +26,7 @@ let
|
|||||||
testAgeSecret = "AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQPQQ94XCHF";
|
testAgeSecret = "AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQPQQ94XCHF";
|
||||||
testAgePublic = vaculib.outputOf {
|
testAgePublic = vaculib.outputOf {
|
||||||
name = "test-age-public-key.txt";
|
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 = {
|
sopsConfig = {
|
||||||
creation_rules = [
|
creation_rules = [
|
||||||
|
@@ -40,7 +40,7 @@ let
|
|||||||
cp {definitions,elements}.units "$out"
|
cp {definitions,elements}.units "$out"
|
||||||
ln -s ${../units/currency.units} "$out"/currency.units
|
ln -s ${../units/currency.units} "$out"/currency.units
|
||||||
ln -s ${../units/cpi.units} "$out"/cpi.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
|
in
|
||||||
@@ -104,8 +104,8 @@ in
|
|||||||
#
|
#
|
||||||
|
|
||||||
output="$(${lib.getExe config.vacu.units.finalPackage} --check)"
|
output="$(${lib.getExe config.vacu.units.finalPackage} --check)"
|
||||||
echo "$output"
|
printf '%s' "$output"
|
||||||
filteredLines="$(echo "$output" \
|
filteredLines="$(printf '%s' "$output" \
|
||||||
| grep -v '^\s*$' \
|
| grep -v '^\s*$' \
|
||||||
| grep -v 'Currency exchange rates from' \
|
| grep -v 'Currency exchange rates from' \
|
||||||
| grep -v 'Consumer price index data from' \
|
| grep -v 'Consumer price index data from' \
|
||||||
|
@@ -34,7 +34,7 @@ let
|
|||||||
keySizeHex = builtins.toString (keySizeBits / 4);
|
keySizeHex = builtins.toString (keySizeBits / 4);
|
||||||
in
|
in
|
||||||
pkgs.runCommand "deterministic-privkey-${name}.pem" { } ''
|
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
|
${pkgs.gnutls}/bin/certtool --generate-privkey --outfile="$out" --key-type=rsa --sec-param=high --seed=$seed
|
||||||
'';
|
'';
|
||||||
generateCert =
|
generateCert =
|
||||||
|
@@ -23,8 +23,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
svl_eprintln() {
|
svl_eprintln() {
|
||||||
echo -n "$@" >&2
|
printf '%s' "$@" >&2
|
||||||
echo
|
printf '\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
_shellvaculib_debug_enabled() {
|
_shellvaculib_debug_enabled() {
|
||||||
|
@@ -14,7 +14,7 @@ in
|
|||||||
fi
|
fi
|
||||||
${pkgs.coreutils}/bin/stty -F ${serialNode} 38400 raw -echoe -echok -echoctl -echoke
|
${pkgs.coreutils}/bin/stty -F ${serialNode} 38400 raw -echoe -echok -echoctl -echoke
|
||||||
for i in 1..5; do
|
for i in 1..5; do
|
||||||
echo -e -n 'set_speed 10\r' > ${serialNode}
|
printf 'set_speed 10\r' > ${serialNode}
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
@@ -46,7 +46,7 @@ writers.writeBashBin "update-git-keys" ''
|
|||||||
# declare -p curl_common
|
# declare -p curl_common
|
||||||
echo GET "$url_keys"
|
echo GET "$url_keys"
|
||||||
resp="$("''${curl_common[@]}" "$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"
|
echo DELETE "$url"
|
||||||
"''${curl_common[@]}" "$url" -X DELETE
|
"''${curl_common[@]}" "$url" -X DELETE
|
||||||
done
|
done
|
||||||
|
@@ -69,7 +69,7 @@ let
|
|||||||
);
|
);
|
||||||
sopsTestSecretsFolder = pkgs.runCommand "test-secrets-encrypted" { } ''
|
sopsTestSecretsFolder = pkgs.runCommand "test-secrets-encrypted" { } ''
|
||||||
mkdir -p "$out"/liam
|
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 =
|
mailtestModule =
|
||||||
{
|
{
|
||||||
@@ -228,26 +228,6 @@ in
|
|||||||
let
|
let
|
||||||
borgCfg = nodes.liam.vacu.liam.backup;
|
borgCfg = nodes.liam.vacu.liam.backup;
|
||||||
user = borgCfg.rsyncUser;
|
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
|
in
|
||||||
{
|
{
|
||||||
users.users.${user} = {
|
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()
|
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("install -d --owner=fm2382 --mode=0700 /home/fm2382/.ssh")
|
||||||
rsyncnet.succeed(
|
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")
|
rsyncnet.succeed("sudo -u fm2382 borg-init")
|
||||||
liam.succeed("systemctl start auto-borg.service")
|
liam.succeed("systemctl start auto-borg.service")
|
||||||
|
Reference in New Issue
Block a user