Skip to content

Instantly share code, notes, and snippets.

View frgaudet's full-sized avatar
🏠
Working from home

Frédéric Gaudet frgaudet

🏠
Working from home
View GitHub Profile
@frgaudet
frgaudet / gist:4a373ace85703ee6e7a5
Created December 2, 2014 09:05
How to make VLC your default video application
grep "^MimeType=" /usr/share/applications/vlc.desktop | \
cut -d "=" -f 2 | \
xargs -d ';' -n 1 | \
grep -e "^video/" -e "^x-content/video" | \
xargs -n 1 -I '{}' \
xdg-mime default vlc.desktop '{}'
@frgaudet
frgaudet / gist:2f83054cf84b9bc8dee2
Created December 2, 2014 09:20
How to disable sf email sending
sed -i \
-e 's@PS_EMAIL_ALERT = "1"@PS_EMAIL_ALERT = "0"@' \
-e 's@LF_EMAIL_ALERT = "1"@LF_EMAIL_ALERT = "0"@' \
-e 's@CT_EMAIL_ALERT = "1"@CT_EMAIL_ALERT = "0"@' \
-e 's@LF_PERMBLOCK_ALERT = "1"@LF_PERMBLOCK_ALERT = "0"@' /etc/csf/csf.conf
@frgaudet
frgaudet / gist:cb47f72e9b29cc9178eb
Created December 2, 2014 09:22
Using CSF to limit connections
# 1 rsync connection
cat << EOF > /etc/csf/csfpre.sh
iptables -A INPUT -p tcp --syn --dport 873 -m connlimit --connlimit-above 1 -j REJECT
EOF
# 4 HTTP connection
cat << EOF > /etc/csf/csfpre.sh
iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 4 -j REJECT
EOF
#!/bin/bash
TARGET="~/temp"
listvms=`VBoxManage list runningvms | awk '{ print $2 }'`
IFS=$(echo -en "\n\b")
for vm in $listvms
do
date=`date +"%Y%m%d-%N"`
VBoxManage controlvm $vm screenshotpng $TARGET/$date.png
done
@frgaudet
frgaudet / gist:b06ac93c16014192ec98
Last active December 4, 2020 14:56
Create a rabbitmq administrator user
rabbitmqctl add_user fred changeme
rabbitmqctl set_user_tags fred administrator
rabbitmqctl set_permissions fred ".*" ".*" ".*"
@frgaudet
frgaudet / openstack-delete-instance.sh
Last active November 28, 2023 15:27
Delete instance from database
#!/bin/bash
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@frgaudet
frgaudet / install_puppet_agent.sh
Last active December 4, 2020 15:13
Install puppet agent on a running computer/VM
SERVER=foreman
cat > /etc/apt/sources.list.d/puppetlabs.list << EOF
deb http://apt.puppetlabs.com trusty main
deb-src http://apt.puppetlabs.com trusty main
deb http://apt.puppetlabs.com trusty dependencies
deb-src http://apt.puppetlabs.com trusty main dependencies
EOF
apt-get update
@frgaudet
frgaudet / apply_hostname
Created May 25, 2015 06:48
Apply hostname from DNS
#!/bin/sh
# Apply hostname from DNS server
# Author : F-Gaudet 2014
# Usage : drop this file into /etc/NetworkManager/dispatcher.d
interface=$1 status=$2
if [ $status = up ]; then
ip=$(ip addr | grep $interface: -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/' )
string=$(host $ip) > /dev/null
#!/usr/bin/env python
# coding=utf-8
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#!/usr/bin/env python
# coding=utf-8
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of