Skip to content

Instantly share code, notes, and snippets.

@tuxnker
tuxnker / oneliner
Last active December 2, 2016 15:24
reduce the size of a virtual-box disk
VBoxManage clonehd $(ls *.vmdk) box-disk1.vdi --format VDI && \
VBoxManage modifyhd box-disk1.vdi --compact && \
VBoxManage storageattach $(pwd | sed 's#.*/##') --storagectl IDE --device 0 --port 0 --type hdd --medium "box-disk1.vdi" && \
rm -f $(ls *.vmdk)
@tuxnker
tuxnker / utf-8_email_rfc6531.py
Last active June 18, 2016 18:34
Python script to send emails to internationalized addresses rfc6531
#!/usr/bin/env python3.5
#requires python 3.5
#testing rfc6531
#coding: utf-8
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email import charset
from email.generator import Generator
import smtplib
#!/bin/bash
#Move Files in between s3 buckets based on a list
#Use Standard_IA so storage will be cheaper
while [[ $# > 1 ]]
do
key="$1"
case $key in
-f|--file)
FILE="$2"
@tuxnker
tuxnker / gulp_watch_fix
Created April 3, 2016 15:18
fix gulp watch on vagrant shared folder VBOXFS/SMB/NFS/
# Install fswatch https://github.com/emcrisostomo/fswatch
#
#Use fswatch in polling mode to listen for Created and Updated events and use touch -a to modify the attribute
#this will triger gulp-watch to execute and prevent a loop from fswatch
# when used in polling mode is going to be cpu intensive use with care
#
#
WATCH_PATH=/mnt/VBOX_SHARED/
LOG_FILE=/var/log/fix_gulp_watch.log
fix_gulp_watch(){
cat users-v2.yaml
- name: Add users from users dictionary
#action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.key }},{{ item.value.group }}" append=no
action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.value.group }}" append=yes
with_dict: users
ignore_errors: yes
- name: Add keys from users dictionary
action: authorized_key user={{ item.key }} key="{{ item.value.ssh_key }}" exclusive=yes
with_dict: users
###########
- hosts: all
# remote_user:
sudo: yes
sudo_user: root
tasks:
- script: lsuser-wrapper.sh creates=/tmp/lsuser
- shell: 'getent passwd|egrep "bash|zsh|nologin" |cut -d : -f 6'
register: home_folder
- fetch: src=/tmp/lsuser dest=reports/remote-authorized/lsuser-{{ ansible_hostname }} flat=yes
- file: path=/tmp/lsuser state=absent
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Specify the environment you want to run the report on as defined in ansible hosts"
exit 1
fi
ANSIBLE_GROUP=$1
USER=$2
#clear save-user fingerprint
rm -f /tmp/local_users
#!/bin/bash
fn_lsuser(){
USER=$1
DATA1=`grep -w $USER /etc/passwd`
SNAME=`echo $DATA1 | cut -d: -f1`
SID=`echo $DATA1 | cut -d: -f3`
SGPNUM=`echo $DATA1 | cut -d: -f4`
SHOME=`echo $DATA1 | cut -d: -f6`
function max(arr, big) {
big = 0;
for (i in cat) {
if (cat[i] > big) { big=cat[i]; }
}
return big
}
NF > 0 {
cat[$1]++;
#!/bin/bash
_APP_PATH=('/home/user1' '/home/user2' '/home/user3')
_PERM=('755' '740' '740')
aLen=${#_APP_PATH[@]}
pLen=${#_PERM[@]}
if [ ${aLen} != ${pLen} ];then
echo "folder and permisons array don't match "
exit 1
fi