feat: Add conf-tool
This commit is contained in:
parent
d2565e5a66
commit
5610b03e84
15
Makefile
15
Makefile
|
@ -1,11 +1,18 @@
|
||||||
CHANNEL=stable
|
CHANNEL=$(shell bash conf-tool.sh read CHANNEL)
|
||||||
ENV=dev
|
ENV=$(shell bash conf-tool.sh read ENV)
|
||||||
|
DEVICE_IP=$(shell bash conf-tool.sh read DEVICE_IP)
|
||||||
|
DEVICE_USERNAME=$(shell bash conf-tool.sh read DEVICE_USERNAME)
|
||||||
|
DEVICE_PORT=$(shell bash conf-tool.sh read DEVICE_PORT)
|
||||||
|
USER_KEY=$(shell bash conf-tool.sh read USER_KEY)
|
||||||
|
USER_EMAIL=$(shell bash conf-tool.sh read USER_EMAIL)
|
||||||
|
|
||||||
|
all:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.img *.model *.manifest snaps
|
rm -rf *.img *.model *.manifest snaps
|
||||||
|
|
||||||
%.model: boards/%.yaml # sign a model file
|
%.model: boards/%.yaml # sign a model file
|
||||||
cat definition.yaml $< | python -c "import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=2)" | sed "s|TIMESTAMP|$(shell date -Iseconds --utc)|g" | snap sign -k default > $@
|
cat definition.yaml $< | python -c "import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=2)" | sed "s|TIMESTAMP|$(shell date -Iseconds --utc)|g" | snap sign -k "$USER_KEY" > $@
|
||||||
snaps/%: deps/%.yaml
|
snaps/%: deps/%.yaml
|
||||||
node build-tool.js --env $(ENV) --channel $(CHANNEL) --board $*
|
node build-tool.js --env $(ENV) --channel $(CHANNEL) --board $*
|
||||||
%.img: %.model snaps/% $(ENV).cloud-init.yaml # build an image
|
%.img: %.model snaps/% $(ENV).cloud-init.yaml # build an image
|
||||||
|
@ -18,4 +25,4 @@ vm.img: amd64.img # make a copy of the newest clean image
|
||||||
start: vm.img # launch the image with kvm
|
start: vm.img # launch the image with kvm
|
||||||
kvm -smp 2 -m 1500 -netdev user,id=mynet0,hostfwd=tcp::8022-:22,hostfwd=tcp::8090-:80 -device virtio-net-pci,netdev=mynet0 -drive file=vm.img,format=raw
|
kvm -smp 2 -m 1500 -netdev user,id=mynet0,hostfwd=tcp::8022-:22,hostfwd=tcp::8090-:80 -device virtio-net-pci,netdev=mynet0 -drive file=vm.img,format=raw
|
||||||
ssh: # ssh into it (don't check the key because that one changes after every rebuild)
|
ssh: # ssh into it (don't check the key because that one changes after every rebuild)
|
||||||
ssh mkg20001@localhost -p 8022 -o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null
|
ssh $(DEVICE_USERNAME)@$(DEVICE_IP) -p $(DEVICE_PORT) -o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo -e "ERROR: $1" 1>&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "x$1" == "xread" ]; then
|
||||||
|
if [ ! -e .config ]; then
|
||||||
|
die "No config found. Run '$ bash conf-tool.sh'"
|
||||||
|
fi
|
||||||
|
. .config
|
||||||
|
echo "${!2}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
signing_key=$(snap keys | tail -n 1 | sed "s| |\n|g" | head -n 1) # value if no key exists: "No"
|
||||||
|
user_email=$(snap whoami | sed "s|email: ||g") # value if not signed in: "-"
|
||||||
|
|
||||||
|
read_prompt() {
|
||||||
|
read -p "> Enter $1 (default $2$3): " val
|
||||||
|
if [ -z "$val" ]; then
|
||||||
|
val="$2"
|
||||||
|
fi
|
||||||
|
echo "< $val"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$user_email" == "-" ]; then
|
||||||
|
die "User email is not set up. Please run:\n\n\t$ snap login"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$signing_key" == "No" ]; then
|
||||||
|
die "Signing key is not set up. https://tutorials.ubuntu.com/tutorial/create-your-own-core-image#3"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dev_user=$(echo "$user_email" | sed "s|@.*||g")
|
||||||
|
|
||||||
|
read_prompt "Device channel" "stable"
|
||||||
|
channel="$val"
|
||||||
|
read_prompt "Device environment" "dev" " - use prod for production"
|
||||||
|
dev_env="$val"
|
||||||
|
|
||||||
|
read_prompt "Development device username" "$dev_user" " - taken from user email"
|
||||||
|
dev_user="$val"
|
||||||
|
read_prompt "Development device address" "localhost" " - for qemu emulation"
|
||||||
|
dev_addr="$val"
|
||||||
|
read_prompt "Development device port" "8022" " - for qemu emulation, use 22 for real device"
|
||||||
|
dev_port="$val"
|
||||||
|
|
||||||
|
vals="CHANNEL=$channel
|
||||||
|
ENV=$dev_env
|
||||||
|
DEVICE_IP=$dev_addr
|
||||||
|
DEVICE_USERNAME=$dev_user
|
||||||
|
DEVICE_PORT=$dev_addr
|
||||||
|
USER_KEY=$signing_key
|
||||||
|
USER_EMAIL=$user_email"
|
||||||
|
|
||||||
|
echo "Is this correct: $vals"
|
||||||
|
|
||||||
|
read -p "[y/N]" v # TODO: use
|
||||||
|
|
||||||
|
echo "$vals" > .config
|
Loading…
Reference in New Issue