Skip to content

Instantly share code, notes, and snippets.

View imrehg's full-sized avatar
🐒
Chaos Monkey

Gergely Imreh imrehg

🐒
Chaos Monkey
View GitHub Profile
@imrehg
imrehg / delta_test.sh
Last active November 6, 2018 23:09
Delta test
AUTH_TOKEN=
SRC_RELEASE_ID=
DEST_RELEASE_ID=
IMG_SRC=$(curl --silent -H "Authorization: Bearer $AUTH_TOKEN" "https://api.balena-cloud.com/v4/image?\$filter=is_part_of__release/release%20eq%20${SRC_RELEASE_ID}" | jq -r '.d[0].id')
IMG_DEST=$(curl --silent -H "Authorization: Bearer $AUTH_TOKEN" "https://api.balena-cloud.com/v4/image?\$filter=is_part_of__release/release%20eq%20${DEST_RELEASE_ID}" | jq -r '.d[0].id')
echo "Source Image -> Destination Image"
echo "$IMG_SRC -> $IMG_DEST"
May 22 13:44:40 3ac63e7 systemd[1]: balena.service: Service hold-off time over, scheduling restart.
May 22 13:44:40 3ac63e7 systemd[1]: Stopped Balena Application Container Engine.
May 22 13:44:40 3ac63e7 systemd[1]: Starting Balena Application Container Engine...
May 22 13:44:40 3ac63e7 healthdog[15062]: time="2018-05-22T13:44:40Z" level=warning msg="Running experimental build"
May 22 13:44:40 3ac63e7 healthdog[15062]: time="2018-05-22T13:44:40.313203379Z" level=info msg="libcontainerd: new containerd process, pid: 15079"
May 22 13:44:40 3ac63e7 healthdog[15062]: time="2018-05-22T13:44:40.519566295Z" level=error msg="containerd: notify OOM events" error="open /proc/1350/cgroup: no such file or direct
May 22 13:44:41 3ac63e7 healthdog[15062]: time="2018-05-22T13:44:41.326064905Z" level=warning msg="libcontainerd: unknown container 5e85a5a91a0b88066d0fd3fda78d70d7626296566fdac9dda
May 22 13:44:41 3ac63e7 healthdog[15062]: unexpected fault address 0xffffffe8
May 22 13:44:41 3ac63e7 healthdog[15062]: fatal error
@imrehg
imrehg / http_connect_proxy_test.md
Last active April 10, 2018 09:52
Proxy testing for resinOS

HTTP Proxy Test

Test

1) Proxy setup

Connect to the target device's host OS, and create the system-proxy directory:

mkdir -p /mnt/boot/system-proxy/
#the RESIN_API_KEY and RESIN_APP_ID is available in the application container, if enabled
curl -v -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${RESIN_API_KEY}" \
'https://api.resin.io/v4/service?$filter=application%20eq%20'${RESIN_APP_ID}'&$select=id,service_name'
@imrehg
imrehg / supervisor_test_api.md
Last active April 10, 2018 09:13
Testing stuff

Supervisor update test through the API

Test

This test checks if the update-resin-supervisor script correctly gets the supervisor information from the API.

  • connect to the host OS
  • copy and paste the below script into the shell to run it - it will take the device's credentials, calls the API for the supervisor for cross-check, update the API entry for this device, and calls the supervisor updater to check if it finds the updated info.
@imrehg
imrehg / redsocks.conf
Created December 12, 2017 16:39
resinOS socks proxy example
base {
log_debug = off;
log_info = on;
log = stderr;
daemon = off;
redirector = iptables;
}
redsocks {
type = socks5;
@imrehg
imrehg / openvpn-connman.log
Created October 23, 2017 12:01
openvpn-connman
openvpn log:
Oct 23 11:50:24 raspberrypi3 openvpn[415]: [[1;39m[server] Inactivity timeout (--ping-restart), restarting[[0m
Oct 23 11:50:24 raspberrypi3 openvpn[415]: [[1;39m/etc/openvpn/downscript.sh resin-vpn 1500 1544 10.2.6.167 52.4.252.97 restart[[0m
Oct 23 11:50:24 raspberrypi3 openvpn[415]: [[1;39mSIGUSR1[soft,ping-restart] received, process restarting[[0m
Oct 23 11:50:24 raspberrypi3 openvpn[415]: [[1;39mRestart pause, 10 second(s)[[0m
Oct 23 11:50:34 raspberrypi3 openvpn[415]: [[1;39mNOTE: the current --script-security setting may allow this configuration to call user-defined scripts[[0m
Oct 23 11:50:34 raspberrypi3 openvpn[415]: [[1;39mSocket Buffers: R=[87380->87380] S=[16384->16384][[0m
Oct 23 11:50:35 raspberrypi3 openvpn[415]: [[1;39mAttempting to establish TCP connection with [AF_INET]52.5.48.142:443 [nonblock][[0m
Oct 23 11:50:36 raspberrypi3 openvpn[415]: [[1;39mTCP connection established with [AF_INET]52.5.48.142:443[[0m
/*
* Thread configuration for each thread. Make sure it matches the number above.
* low_power_mode - This mode will double the cache usage, and double the single thread performance. It will
* consume much less power (as less cores are working), but will max out at around 80-85% of
* the maximum performance.
*
* no_prefetch - Some sytems can gain up to extra 5% here, but sometimes it will have no difference or make
* things slower.
*
* affine_to_cpu - This can be either false (no affinity), or the CPU core number. Note that on hyperthreading
@imrehg
imrehg / copycmd.sh
Last active May 29, 2017 14:47
system copier for resin devices
#!/bin/bash
# Copy everything up intil resin-data (mmcblk0p6 usually)
# and send it over the ssh connection, compressed
DEVICE=/dev/mmcblk0
PARTITION=mmcblk0p5
# Get partition end position in blocks
FSSIZE=$(/sbin/fdisk -l -o Device,End ${DEVICE} | grep ${PARTITION} | awk '{ print $2 }')
# Copy data, compress, and send over STDOUT
/bin/dd if=/dev/mmcblk0 conv=sync,noerror bs=512 status=none count=${FSSIZE} | gzip -c
#!/bin/bash
set -o pipefail
# Help function
function update-resin-supervisor-help {
cat << EOF
Wrapper to run supervisor agent updates on resin distributions.
$0 <OPTION>
Options: