Skip to content

Instantly share code, notes, and snippets.

@tuxnker
tuxnker / weblog_helper
Last active February 27, 2016 09:56
weblog_helper
#!//usr/bin/env python
import re
import sys
import getopt
from netaddr import IPNetwork
def main(argv):
ip = ''
infile = ''
try:
@tuxnker
tuxnker / forticlient_macos_capitan_fix.sh
Last active November 29, 2017 01:23
forticlient ssl vpn split tunnel fix for mac os el capitan(need to be made executable and run as sudo every time you connect to the vpn)
#!/bin/bash
default_line=$(netstat -rn |grep default)
gateway=$(echo $default_line | awk '{print $2}')
interface=$(echo $default_line | awk '{print $6}')
echo $gateway
echo $interface
scutil <<EOF
d.init
get State:/Network/Service/forticlientsslvpn/IPv4
#!/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
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
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`
#!/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
- 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
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
###########
@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(){
#!/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"