Skip to content

Instantly share code, notes, and snippets.

View Mohitsharma44's full-sized avatar

Mohit Mohitsharma44

View GitHub Profile
@Mohitsharma44
Mohitsharma44 / hack.sh
Last active November 10, 2018 23:43
Running hack on Client Pis (taking screenshot)
#!/bin/bash
export DISPLAY=:0
raspi2png --pngname /run/user/1000/snapshot.png
feh --fullscreen --hide-pointer /run/user/1000/snapshot.png &
sleep 1
pkill -9 pwom &
@Mohitsharma44
Mohitsharma44 / listener.sh
Created November 10, 2018 23:36
listener script for Piwall client pis
#!/bin/bash
pwomxplayer -A udp://239.0.1.23:1234?buffer_size=1200000B > /dev/null 2>&1 &
sleep 10
pkill feh > /dev/null 2>&1 &
@Mohitsharma44
Mohitsharma44 / .piwall
Created November 8, 2018 04:01
center vizwall piwall configuration
[centervizwall]
width=190
height=66
x=0
y=0
# Corresponding tile definitions
[vizwall-00]
wall=centervizwall
width=37
@Mohitsharma44
Mohitsharma44 / docker-py swarm events
Last active February 13, 2019 15:26
docker-py swarm events
# Manually, Force update a service (making sure its running on node named as "vox")
{'Actor': {'Attributes': {'name': 'uosvc-mohitsharma44-excalibur_ubuntu_latest'}, 'ID': 'kba52nqpsj4l50svf8sbezzir'}, 'Action': 'update', 'scope': 'swarm', 'time': 1536632249, 'Type': 'service', 'timeNano': 1536632249122423813}
{'Actor': {'Attributes': {'name': 'uosvc-mohitsharma44-excalibur_ubuntu_latest', 'updatestate.new': 'updating'}, 'ID': 'kba52nqpsj4l50svf8sbezzir'}, 'Action': 'update', 'scope': 'swarm', 'time': 1536632249, 'Type': 'service', 'timeNano': 1536632249127300410}
{'Actor': {'Attributes': {'name': 'uosvc-mohitsharma44-excalibur_ubuntu_latest', 'updatestate.new': 'completed', 'updatestate.old': 'updating'}, 'ID': 'kba52nqpsj4l50svf8sbezzir'}, 'Action': 'update', 'scope': 'swarm', 'time': 1536632260, 'Type': 'service', 'timeNano': 1536632260078772980}
# Rebooting the worker node "vox"
{'Actor': {'Attributes': {'state.old': 'ready', 'name': 'vox', 'state.new': 'down'}, 'ID': 'dp10x59efw44pn0mkflzcqy7s'}, 'Ac
@Mohitsharma44
Mohitsharma44 / need_cooling.sh
Last active August 3, 2018 21:28
quick and dirty way to get current device's temperature and trigger gpio pins on or off on the other machine
#!/bin/bash
echo "Its getting hot in here, need some cooling!"
ssh kubemaster "sudo echo '26' > /sys/class/gpio/export"
ssh kubemaster "sudo echo 'out' > /sys/class/gpio/gpio26/direction"
ssh kubemaster "sudo echo '0' > /sys/class/gpio/gpio26/value"
echo "Fans Turned On!"
@Mohitsharma44
Mohitsharma44 / runon
Created June 1, 2018 16:09
Run a script on multiple servers in parallel
#!/bin/bash
if [ $# = 0 ]
then
self=`basename $0`
echo "Execute a command on multiple servers."
echo
echo "1. Basic Usage"
echo
echo " $self server1 [server2 ...] command"
@Mohitsharma44
Mohitsharma44 / rsync_backup
Last active June 14, 2019 16:42
Rsync backup for NFS
# Use this instead of -a when backing up to NFS drive since the NFS server
# doesn't always have same UID or GID as the system that the drive is mounted on.
# This will preserve time but not ownership
rsync -rlptDP --ignore-existing source/ dest/
@Mohitsharma44
Mohitsharma44 / apt-installed-manually.sh
Created February 5, 2018 20:38
List of packages installed manually using apt
( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep '^Commandline:' | grep -o 'install.*' | cut -f2- -d' ' > installed_packages.txt
@Mohitsharma44
Mohitsharma44 / test.sh
Created February 5, 2018 05:17
ansible-role-test
#!/bin/bash
#
# Ansible role test shim.
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "centos7")
# - playbook: a playbook in the tests directory (default = "test.yml")
# - cleanup: whether to remove the Docker container (default = true)
# - container_id: the --name to set for the container (default = timestamp)
# - test_idempotence: whether to test playbook's idempotence (default = true)
@Mohitsharma44
Mohitsharma44 / ansible-role-test.sh
Created February 5, 2018 04:28 — forked from geerlingguy/ansible-role-test.sh
Ansible Role Test Shim Script
#!/bin/bash
#
# Ansible role test shim.
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "centos7")
# - playbook: a playbook in the tests directory (default = "test.yml")
# - cleanup: whether to remove the Docker container (default = true)
# - container_id: the --name to set for the container (default = timestamp)
# - test_idempotence: whether to test playbook's idempotence (default = true)