112 lines
2.9 KiB
Nix
112 lines
2.9 KiB
Nix
{ ... }:
|
|
{
|
|
programs.zsh.initExtra = ''
|
|
if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ];
|
|
then
|
|
source $HOME/.nix-profile/etc/profile.d/nix.sh
|
|
fi
|
|
|
|
function sc-log {
|
|
ssh smartcan "SYSTEMD_COLORS=true journalctl --follow --no-tail --unit smartcan-''${1:-*}"
|
|
}
|
|
|
|
function sc-restart {
|
|
ssh smartcan "systemctl restart smartcan-''${1}"
|
|
}
|
|
|
|
function fu-build {
|
|
./kas-container build kas/kas-ttc-image-horsch.yml
|
|
}
|
|
|
|
function fu-build-dev {
|
|
./kas-container build kas/kas-ttc-image-horsch-dev.yml
|
|
}
|
|
|
|
function fu-reboot {
|
|
ssh fusion "reboot"
|
|
}
|
|
|
|
function fu-swu {
|
|
local ssh_login="fusion"
|
|
local update_file=''${1}
|
|
|
|
if [ -z ''${update_file} ]; then
|
|
update_file=$(find build/tmp/deploy/images -name "*.swu" -type f | fzf --select-1)
|
|
fi
|
|
|
|
if [ -z ''${update_file} ]; then
|
|
echo "no file selected"
|
|
return 1
|
|
fi
|
|
|
|
if [ ! -f ''${update_file} ]; then
|
|
echo "file \"''${update_file}\" does not exist"
|
|
return 2
|
|
fi
|
|
|
|
echo "flashing ''${update_file} to device..."
|
|
cat "''${update_file}" | ssh ''${ssh_login} "swupdate-client -"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "update failed"
|
|
return 3
|
|
fi
|
|
|
|
echo "rebooting device"
|
|
ssh ''${ssh_login} reboot
|
|
|
|
echo "done."
|
|
}
|
|
|
|
function fu-wic {
|
|
local fzf_preview='stat --printf "%n\nSize: %s bytes\nModified: %y" {}'
|
|
|
|
uuu.exe -lsusb | grep --silent MX8QM
|
|
if [ ''$? -eq 0 ]; then
|
|
echo "fusion found"
|
|
else
|
|
echo "fusion not connected"
|
|
return 1
|
|
fi
|
|
|
|
local bootloader_file=''${1}
|
|
local wic_file=''${2}
|
|
|
|
if [ -z ''${bootloader_file} ]; then
|
|
bootloader_file=$(find build/tmp/deploy/images -name "imx-boot-horsch-fusion-sd*" -type f \
|
|
| fzf --select-1 --exit-0 --header "Select a bootloader file" --preview=''${fzf_preview} --preview-window=top)
|
|
fi
|
|
|
|
if [ -z ''${bootloader_file} ]; then
|
|
echo "no bootloader file selected"
|
|
return 1
|
|
fi
|
|
|
|
if [ -z ''${wic_file} ]; then
|
|
wic_file=$(find build/tmp/deploy/images -name "*.wic" -type f \
|
|
| fzf --select-1 --exit-0 --header="Select a wic image file" --preview=''${fzf_preview} --preview-window=top)
|
|
fi
|
|
|
|
if [ -z ''${wic_file} ]; then
|
|
echo "no wic file selected"
|
|
return 1
|
|
fi
|
|
|
|
echo "flashing ''${wic_file} to device..."
|
|
uuu.exe -v -b emmc_all ''${bootloader_file} ''${wic_file}
|
|
|
|
echo "done."
|
|
}
|
|
|
|
function hb-configs {
|
|
curl --silent \
|
|
--location "https://hawkbit-smartcan.horsch.com/rest/v1/softwaremodules" \
|
|
--header "Content-Type: application/json" \
|
|
--header "Authorization: Basic ''$hawkbitToken" \
|
|
--data "q=type==configfs-smartcan" \
|
|
--data "sort=id:DESC" \
|
|
--get \
|
|
| jq | bat
|
|
}
|
|
'';
|
|
}
|