Skip to content

Commit

Permalink
chore: format shell scripts (evcc-io#17674)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Dec 9, 2024
1 parent 782f83c commit 7a7d5aa
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 209 deletions.
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
printWidth: 100,
trailingComma: "es5",
plugins: ["prettier-plugin-sh"],
};
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "vite build",
"test": "TZ=Europe/Berlin vitest",
"lint": "prettier assets './**/*.{yml,yaml}' --write && eslint assets/**/*.js assets/**/*.vue --fix --max-warnings=0",
"lint": "prettier assets './**/*.{yml,yaml,sh}' --write && eslint assets/**/*.js assets/**/*.vue --fix --max-warnings=0",
"dev": "vite",
"histoire": "histoire dev",
"playwright": "playwright test --ui",
Expand Down Expand Up @@ -47,6 +47,7 @@
"histoire": "^0.17.0",
"markty-toml": "^0.1.1",
"prettier": "^3.0.0",
"prettier-plugin-sh": "^0.14.0",
"prettier-plugin-toml": "^2.0.1",
"rollup-plugin-visualizer": "^5.8.3",
"smoothscroll-polyfill": "^0.4.4",
Expand All @@ -69,4 +70,4 @@
},
"license": "MIT",
"repository": "github:evcc-io/evcc"
}
}
46 changes: 23 additions & 23 deletions packaging/docker/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ set -e
HASSIO_OPTIONSFILE=/data/options.json

if [ -f ${HASSIO_OPTIONSFILE} ]; then
CONFIG=$(grep -o '"config_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')
echo "Using config file: ${CONFIG}"
CONFIG=$(grep -o '"config_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')
echo "Using config file: ${CONFIG}"

SQLITE_FILE=$(grep -o '"sqlite_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')
SQLITE_FILE=$(grep -o '"sqlite_file": "[^"]*' ${HASSIO_OPTIONSFILE} | grep -o '[^"]*$')

if [ ! -f "${CONFIG}" ]; then
echo "Config not found. Please create a config under ${CONFIG}."
echo "For details see evcc documentation at https://github.com/evcc-io/evcc#readme."
else
if [ "${SQLITE_FILE}" ]; then
echo "starting evcc: 'EVCC_DATABASE_DSN=${SQLITE_FILE} evcc --config ${CONFIG}'"
exec env EVCC_DATABASE_DSN="${SQLITE_FILE}" evcc --config "${CONFIG}"
else
echo "starting evcc: 'evcc --config ${CONFIG}'"
exec evcc --config "${CONFIG}"
fi
fi
if [ ! -f "${CONFIG}" ]; then
echo "Config not found. Please create a config under ${CONFIG}."
echo "For details see evcc documentation at https://github.com/evcc-io/evcc#readme."
else
if [ "${SQLITE_FILE}" ]; then
echo "starting evcc: 'EVCC_DATABASE_DSN=${SQLITE_FILE} evcc --config ${CONFIG}'"
exec env EVCC_DATABASE_DSN="${SQLITE_FILE}" evcc --config "${CONFIG}"
else
echo "starting evcc: 'evcc --config ${CONFIG}'"
exec evcc --config "${CONFIG}"
fi
fi
else
if [ "$1" = 'evcc' ]; then
shift
exec evcc "$@"
elif expr "$1" : '-.*' > /dev/null; then
exec evcc "$@"
else
exec "$@"
fi
if [ "$1" = 'evcc' ]; then
shift
exec evcc "$@"
elif expr "$1" : '-.*' > /dev/null; then
exec evcc "$@"
else
exec "$@"
fi
fi
161 changes: 80 additions & 81 deletions packaging/gokrazy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,99 +5,98 @@ arch="${MACHINE:=amd64}"
os=""

if [ "$(uname)" == "Darwin" ]; then
os="darwin"
os="darwin"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
os="linux"
os="linux"
fi


case $arch in
# arm64 emulator with kernel auto loading
arm64)
args=(
-name gokrazy-arm64
-m 3G
-smp 2
-M virt,highmem=off
-cpu cortex-a72
-nographic
-drive file=${imagefile},format=raw
-bios ./packaging/gokrazy/QEMU_EFI.fd
)
# arm64 emulator with kernel auto loading
arm64)
args=(
-name gokrazy-arm64
-m 3G
-smp 2
-M virt,highmem=off
-cpu cortex-a72
-nographic
-drive file=${imagefile},format=raw
-bios ./packaging/gokrazy/QEMU_EFI.fd
)

if [[ "$os" == "darwin" ]]; then
args+=(-nic vmnet-shared)
else
args+=(-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22)
args+=(-device e1000,netdev=net0)
fi
qemu-system-aarch64 "${args[@]}"
;;
if [[ "$os" == "darwin" ]]; then
args+=(-nic vmnet-shared)
else
args+=(-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22)
args+=(-device e1000,netdev=net0)
fi
qemu-system-aarch64 "${args[@]}"
;;

# raspi3b emulator with manual kernel loading
# requires kernel (./vmlinuz) and dtb file extraction from the drive.img,
# to be used as an arg (with -dtb, -kernel and -append)
# to instruct the vm on how to load the kernel
raspi3b)
if [[ "$os" == "darwin" ]]; then
args+=(-nic vmnet-shared)
fi
# raspi3b emulator with manual kernel loading
# requires kernel (./vmlinuz) and dtb file extraction from the drive.img,
# to be used as an arg (with -dtb, -kernel and -append)
# to instruct the vm on how to load the kernel
raspi3b)
if [[ "$os" == "darwin" ]]; then
args+=(-nic vmnet-shared)
fi

# Only works with qemu === v5.2.0
# because for lower versions networking is missing.
# It was introduced in qemu v5.2.0 via usb networking (-device usb-net), but it is very very slow at the point that gokrazy network updates fail.
# For qemu versions >= v6.0.0, the /gokrazy/init process crashes early at gokrazy.Boot(). To be investigated.
qemu_version="$(qemu-system-aarch64 --version | sed -nr 's/^.*version\s([.0-9]*).*$/\1/p')"
if [[ "$qemu_version" != "5.2.0" ]]; then
# Only works with qemu === v5.2.0
# because for lower versions networking is missing.
# It was introduced in qemu v5.2.0 via usb networking (-device usb-net), but it is very very slow at the point that gokrazy network updates fail.
# For qemu versions >= v6.0.0, the /gokrazy/init process crashes early at gokrazy.Boot(). To be investigated.
qemu_version="$(qemu-system-aarch64 --version | sed -nr 's/^.*version\s([.0-9]*).*$/\1/p')"
if [[ "$qemu_version" != "5.2.0" ]]; then
echo "error: incompatible qemu-system-aarch64 version: $qemu_version. gokrazy on raspi3b can only run on 5.2.0"
exit 1;
fi
exit 1
fi

# Extract the kernel (vmlinuz) and the dtb file from the drive.img first
./extract_kernel.sh
args=(
-name gokrazy-arm64-raspi3b
-m 1024
-no-reboot
-M raspi3b
-append "console=tty1 console=ttyAMA0,115200 dwc_otg.fiq_fsm_enable=0 root=/dev/mmcblk0p2 init=/gokrazy/init rootwait panic=10 oops=panic"
-dtb ./bcm2710-rpi-3-b-plus.dtb
-nographic
-serial mon:stdio
-drive file=${imagefile},format=raw
-kernel vmlinuz
-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22
-device usb-net,netdev=net0
)
# Extract the kernel (vmlinuz) and the dtb file from the drive.img first
./extract_kernel.sh
args=(
-name gokrazy-arm64-raspi3b
-m 1024
-no-reboot
-M raspi3b
-append "console=tty1 console=ttyAMA0,115200 dwc_otg.fiq_fsm_enable=0 root=/dev/mmcblk0p2 init=/gokrazy/init rootwait panic=10 oops=panic"
-dtb ./bcm2710-rpi-3-b-plus.dtb
-nographic
-serial mon:stdio
-drive file=${imagefile},format=raw
-kernel vmlinuz
-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22
-device usb-net,netdev=net0
)

qemu-system-aarch64 "${args[@]}"
;;
qemu-system-aarch64 "${args[@]}"
;;

# amd64 emulator with kernel auto loading
amd64)
args=(
-name gokrazy-amd64
-m 3G
-smp $(nproc)
-usb
-nographic
-serial mon:stdio
-boot order=d
-drive file=${imagefile},format=raw
)
# amd64 emulator with kernel auto loading
amd64)
args=(
-name gokrazy-amd64
-m 3G
-smp $(nproc)
-usb
-nographic
-serial mon:stdio
-boot order=d
-drive file=${imagefile},format=raw
)

if [[ "$os" == "darwin" ]]; then
args+=(-nic vmnet-shared)
else
args+=(-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22)
args+=(-device e1000,netdev=net0)
fi
if [[ "$os" == "darwin" ]]; then
args+=(-nic vmnet-shared)
else
args+=(-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::2222-:22)
args+=(-device e1000,netdev=net0)
fi

qemu-system-x86_64 "${args[@]}"
;;
qemu-system-x86_64 "${args[@]}"
;;

*)
echo -n "unsupported arch ${arch}"
exit
;;
*)
echo -n "unsupported arch ${arch}"
exit
;;
esac
Loading

0 comments on commit 7a7d5aa

Please sign in to comment.