Added transfer script, dsiabled sleep for server
This commit is contained in:
parent
ba02131eea
commit
ae408e4d9d
4 changed files with 49 additions and 1 deletions
|
|
@ -7,5 +7,6 @@
|
||||||
./starship.nix
|
./starship.nix
|
||||||
./yazi.nix
|
./yazi.nix
|
||||||
./zoxide.nix
|
./zoxide.nix
|
||||||
|
./transfer.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
37
home/shell/transfer.nix
Normal file
37
home/shell/transfer.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
osConfig,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
home.packages = [
|
||||||
|
(pkgs.writeShellScriptBin "transfer" ''
|
||||||
|
PASSWORD=$(sed 's/.*="\(.*\)"/\1/' ${osConfig.age.secrets.transferSh.path})
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$PASSWORD" ]; then
|
||||||
|
echo "Error: Password not found."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
file_path="$1"
|
||||||
|
if [ -z "$file_path" ]; then
|
||||||
|
echo "Usage: transfer <file>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
response=$(curl -sD - --user "jsw:$PASSWORD" --progress-bar --upload-file "$file_path" "https://share.jsw.tf/$(basename "$file_path")")
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
DELETE=$(echo "$response" | grep x-url-delete | sed "s/.*\///")
|
||||||
|
URL=$(echo "$response" | tail -n1)
|
||||||
|
|
||||||
|
echo "Delete code: $DELETE"
|
||||||
|
echo "URL: $URL"
|
||||||
|
else
|
||||||
|
echo "Upload failed."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -4,4 +4,11 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
niksos.server = true;
|
niksos.server = true;
|
||||||
|
|
||||||
|
systemd.sleep.extraConfig = ''
|
||||||
|
AllowSuspend=no
|
||||||
|
AllowHibernation=no
|
||||||
|
AllowHybridSleep=no
|
||||||
|
AllowSuspendThenHibernate=no
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
transferSh.file = ./transfer-sh.age;
|
transferSh = {
|
||||||
|
file = ./transfer-sh.age;
|
||||||
|
owner = "jsw";
|
||||||
|
};
|
||||||
password.file = ./password.age;
|
password.file = ./password.age;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue