AWS EC2 – Change Hostname

Set a CNAME redirection to the EC2 then execute this code


sudo hostnamectl set-hostname newhostname.domain.net

sudo reboot

hostname

Advertisements

Docker container – Run a container with access to the host’s docker daemon and volumes


docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes --mount source=myvol1,target=/vol alpine sh

 

The above command runs a container (alpine image). Inside this container, you have access to the docker daemon of the host as well as the volumes.

Meaning that, from that container, you can manage containers (start, stop, inspect, …)

You can also start new containers with volumes.


apk update && apk add docker

docker run --rm -it --mount source=myvol1,target=/vol alpine sh

 

Netdata in Docker – Monitor my machine

Netdata: https://github.com/netdata/netdata & https://www.netdata.cloud/

is a wonderful tool to monitor a device and trigger alarms

To run it in a second on your local machine, use this docker command

docker run -d --name=netdata -p 19999:19999 -v /proc:/host/proc:ro -v /sys:/host/sys:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --rm --cap-add SYS_PTRACE --security-opt apparmor=unconfined netdata/netdata

Then access the dashboard http://localhost:19999

Systemd – Daemon Hubot (Coffee script)

Here is the content of the file /etc/systemd/system/hubot.service

After creating the file, execute

sudo systemctl daemon-reload && sudo systemctl enable hubot && sudo systemctl start hubot

Replace SLACK_TOKEN below

[Unit]
Description=Hubot
Requires=network.target
After=network.target

[Service]
Type=simple
WorkingDirectory=/home/pi/hubot
User=pi

Restart=always
TimeoutStartSec=10
RestartSec=10

; Configure Hubot environment variables, use quotes around vars with whitespace as shown below.
Environment="HUBOT_SLACK_TOKEN=SLACK_TOKEN"

; which node => /home/pi/.nvm/versions/node/v8.0.0/bin/node
; which coffee (need to install it globally npm install -g coffee-script) => /home/pi/.nvm/versions/node/v8.0.0/bin/coffee
ExecStart=/home/pi/.nvm/versions/node/v8.0.0/bin/node /home/pi/.nvm/versions/node/v8.0.0/bin/coffee /home/pi/hubot/node_modules/hubot/bin/hubot --name pixibot -a slack

[Install]
WantedBy=multi-user.target

Ionic – Manually build an App for Android, like AppFlow does on Ionic Package

When using Ionic Package to build app on the cloud, the executed command is not as trivial as

ionic cordova build android --prod --release

To mimic the behavior performed by Ionic Package, follow those steps:

    1. Add platform Android if needed
    2. ng build –configuration=production –prod –source-map
    3. Edit www/index.html and add this line in the HEAD section
      1. <script src="cordova.js"></script
    4. cordova build android
      1. Add those flags if building for production
        1. –release — –keystore=android.keystore –storePassword=***** –alias=key0_eventflow –password=*****

Why would you do that ? Well, we observed that the build is not exactly the same as on our local machines… so it might be useful.

With this kind of build, you can debug the app with Chrome adb inspect.