Skip to content

Instantly share code, notes, and snippets.

View freyes's full-sized avatar
🥑

Felipe Reyes freyes

🥑
View GitHub Profile
#!/bin/bash
DEVID=$(xinput list --id-only "DLL07F3:01 044E:120B")
PROPID=$(xinput list-props $DEVID | grep "libinput Tapping Enabled (" | cut -d '(' -f2 | cut -d')' -f1)
xinput set-prop $DEVID $PROPID 1
@freyes
freyes / nodes.py
Last active September 9, 2019 20:19
#!/usr/bin/python3
#
# Usage:
# ./nodes.py --url http://localhost:5240/MAAS/ --apikey "someapikey"
# ./nodes.py --url http://localhost:5240/MAAS/ --username foobar --pasword sekret
#
# Example output:
# node01 Deployed 11 days 2019-08-29 18:56:56+00:00
# node02 Deployed 26 days 2019-08-14 13:19:01+00:00
# node03 Deployed 16 hours 2019-09-09 03:55:11+00:00
@freyes
freyes / tcpdump-ping.sh
Created August 21, 2019 22:24
capture pings with tcpdump
tcpdump -nni any "icmp[icmptype] == icmp-echo or icmp[icmptype] == icmp-echoreply"
dialmgo() {
agent=$(cd /var/lib/juju/agents; echo machine-*)
pw=$(sudo cat /var/lib/juju/agents/${agent}/agent.conf |grep statepassword |awk '{ print $2 }')
mongo --ssl --sslAllowInvalidCertificates -u ${agent} -p $pw localhost:37017/juju --authenticationDatabase admin
}
#!/bin/bash -e
# Usage:
# ./read_relation.sh <RELATION> <UNIT> <UNIT_TO_READ_FROM>
# Example:
# ./read_relation.sh identity-service cinder/0 keystone/0
#
# In this example we are reading the data contained in the identity-service
# relation between cinder/0 and keystone/0.
INTERFACE="$1"
#!/bin/bash
# use awesome as window manager
xfconf-query -c xfce4-session -p /sessions/Failsafe/Client0_Command -t string -sa awesome
# disable xfce4-panel
xfconf-query -c xfce4-session -p /sessions/Failsafe/Client2_Command -t string -sa /bin/true
# disable xfdesktop
xfconf-query -c xfce4-session -p /sessions/Failsafe/Client4_Command -t string -sa /bin/true
@freyes
freyes / nginx-default
Last active May 16, 2019 15:14
sync v2 and v3 images in a under ~/public_html/maas/... , remember to configure some http server to serve them
# Default server configuration /etc/nginx/sites-enabled/default
#
server {
listen 80 default_server;
listen [::]:80 default_server;
...
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
index index.html index.htm;
autoindex on;
@freyes
freyes / show_instances_per_project.sh
Created March 21, 2019 19:56
print number of instances running per project
#!/bin/bash
TOTAL_INSTANCES=0
TMPFILE=`mktemp`
nova list --fields tenant_id --all-tenants | tail -n +4 | head -n -2 | cut -d'|' -f3 | tr -d ' ' | sort | uniq -c | sort -n | while read -r LINE; do
TENANT_ID=$(echo $LINE | awk -F' ' '{print $2}')
TENANT_NAME=$(openstack project show -c name -f value $TENANT_ID)
NUM_INSTANCES=$(echo $LINE | awk -F' ' '{print $1}')
echo "$NUM_INSTANCES $TENANT_NAME"
TOTAL_INSTANCES=$(($TOTAL_INSTANCES+$NUM_INSTANCES))
#!/bin/bash
# source: https://github.com/juju/charmstore-client/issues/154#issuecomment-375039544
charm=${1#cs:}
shift
owner="$(charm show "cs:$charm" --format=json | jq -r '.owner.User')"
owner_rev="$(charm show "cs:~$owner/$charm" --format=json | jq -r '."id-revision".Revision')"
owner_url="cs:~$owner/$charm-$owner_rev"
#echo "$owner_url"
charm show "$owner_url" "$@"1
#
# Disable ipv6 in tun* interfaces
# File: /etc/udev/rules.d/99-ipv6-openvpn.rules
SUBSYSTEM=="net", ACTION=="add", KERNEL=="tun*", RUN+="/sbin/sysctl -w net.ipv6.conf.$env{INTERFACE}.disable_ipv6=1"