2024-07-17 12:18:27 +00:00
|
|
|
#!/bin/env fish
|
|
|
|
begin
|
|
|
|
set -l dir (status dirname)
|
|
|
|
source "$dir/../../Scripts/software.fish"
|
|
|
|
|
|
|
|
function configureSW -V dir
|
|
|
|
sudo cp "$dir/rclone.service" "$dir/rclone.target" "$dir/rclone@.service" /etc/systemd/user
|
|
|
|
end
|
|
|
|
|
2024-07-20 03:08:23 +00:00
|
|
|
function userConfig -V dir -a name
|
|
|
|
source "$dir/../../Scripts/config.fish"
|
2024-08-23 16:28:20 +00:00
|
|
|
set -l key "valhalla.linux.users.$name.rclone.configurations"
|
2024-07-20 03:09:13 +00:00
|
|
|
set -l configs (getConfig "$key" --apply "builtins.attrNames" --json)
|
2024-07-20 03:08:23 +00:00
|
|
|
|
|
|
|
if [ (echo "$configs" | jq "length") -gt 0 ]
|
|
|
|
if [ "$XDG_SESSION_TYPE" = "tty" ]
|
|
|
|
set -l entryPoint ~"$name"/.config/autostart/PortValhallaProfile.desktop
|
2024-07-20 03:09:42 +00:00
|
|
|
sudo -u "$name" mkdir -p "$(dirname "$entryPoint")"
|
2024-07-20 03:08:23 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
printf %s\n \
|
|
|
|
"#!/user/bin/env xdg-open" \
|
|
|
|
"[Desktop Entry]" \
|
|
|
|
"Name=PortValhalla Profile" \
|
|
|
|
"Type=Application" \
|
|
|
|
"Terminal=false" (
|
|
|
|
printf "%s " \
|
|
|
|
"Exec=env" \
|
|
|
|
"CONFIG_MODULE=$(echo "$CONFIG_MODULE" | string escape)" \
|
|
|
|
"konsole -e fish $(realpath (status filename) | string escape) userConfig"
|
|
|
|
)
|
|
|
|
end | sudo -u "$name" tee "$entryPoint" > /dev/null
|
|
|
|
|
|
|
|
sudo chmod +x "$entryPoint"
|
2024-07-20 03:14:09 +00:00
|
|
|
sudo -Eu "$name" dbus-launch --exit-with-session startplasma-wayland &> /dev/null
|
2024-07-20 03:08:23 +00:00
|
|
|
rm "$entryPoint"
|
|
|
|
rm ~"$name"/.config/plasma-welcomerc
|
2024-07-30 15:42:29 +00:00
|
|
|
else if [ -n "$name" ] && [ "$name" != "$USER" ]
|
|
|
|
sudo -Eu "$name" CONFIG_MODULE="$CONFIG_MODULE" fish "$(status filename)" userConfig
|
2024-07-20 03:08:23 +00:00
|
|
|
else
|
2024-07-30 15:42:29 +00:00
|
|
|
systemctl --user enable rclone.service
|
2024-07-20 03:08:23 +00:00
|
|
|
echo "Please complete the setup of your rclone configurations!"
|
2024-07-20 11:47:07 +00:00
|
|
|
|
|
|
|
for config in (echo "$configs" | jq '.[]' --raw-output0 | string split0)
|
|
|
|
set -l configKey "$key.$config"
|
|
|
|
set -l duration "$configKey.cacheDuration"
|
|
|
|
|
|
|
|
set -l serviceName "rclone@$config:$(getConfig "$configKey.dirName")"
|
|
|
|
|
|
|
|
if isSet "$duration"
|
|
|
|
set serviceName "$serviceName:$(getConfig "$duration")"
|
|
|
|
end
|
|
|
|
|
|
|
|
echo "Please create a remote called `$config`."
|
|
|
|
rclone config || true
|
|
|
|
systemctl --user enable "$serviceName" --now || true
|
|
|
|
end
|
2024-07-20 03:08:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-07-17 12:18:27 +00:00
|
|
|
runInstaller $argv
|
|
|
|
end
|