Skip to content

Instantly share code, notes, and snippets.

@Guitsou
Guitsou / if-simple.md
Last active December 17, 2015 10:49
Exemple de if sous Bash

Simple

Simple

#!/bin/bash
if [ "foo" = "foo" ]; then
    echo expression evaluated as true
fi

Complet

Gestion

Déclaration des variables

A ajouter en source dans le .bashrc. Sinon, les valeurs devront être passées en paramètre systématiquement...

#!/bin/bash
## my-landscape-api.rc
export LANDSCAPE_API_KEY="Ma clé"
export LANDSCAPE_API_SECRET="Mon secret"
export LANDSCAPE_API_URI="https://URL/api/"
export LANDSCAPE_API_SSL_CA_FILE="/etc/ssl/certs/landscape_server_ca.crt"
@Guitsou
Guitsou / Change_DRAC_password.sh
Last active December 17, 2015 16:49
Dell OpenManage
#!/bin/bash
PASSWORD="toto"
if ! grep -i qemu /proc/cpuinfo > /dev/null; then ## VM ou phys ?
if [ -f /opt/dell/srvadmin/bin/omreport ]; then ## Tools DELL ok ?
ID=$(omreport chassis remoteaccess config=user | grep -B 3 root | awk '/ID/ {print $4}')
echo "ID root : $ID"
echo "Changement de mot de passe..."
omconfig chassis remoteaccess config=user id=$ID newpw=$PASSWORD confirmnewpw=$PASSWORD
@Guitsou
Guitsou / vera.md
Created May 24, 2013 11:46
Domotique en vrac

URL pour obtenir les infos pour l'api :

http://sta1.mios.com/locator_json.php?username=XXX
@Guitsou
Guitsou / ssh_drac.md
Last active December 17, 2015 19:29
Fonctions de la DRAC Dell

Reset de la DRAC

racadm racreset

Redémarrage du serveur

racadm serveraction powercycle
@Guitsou
Guitsou / commands.md
Last active December 17, 2015 19:39
IP vs IFCONFIG

##Show network devices and configuration ¶

ifconfig   # ifconfig way
ip addr show
ip link show

##Enable a network interface ¶

ifconfig eth0 up
ip link set eth0 up
@Guitsou
Guitsou / sendmail.py
Last active December 18, 2015 16:39
Envoyer un email avec une lib python... Source : http://effbot.org/pyfaq/how-do-i-send-mail-from-a-python-script.htm
import smtplib
SERVER = "localhost"
FROM = "[email protected]"
TO = ["[email protected]"] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
@Guitsou
Guitsou / smtp.py
Created June 19, 2013 13:58
Envoyer des mails via SMTP directement
import smtplib
fromaddr = '[email protected]'
toaddrs = '[email protected]'
msg = 'There was a terrible error that occured and I wanted you to know!'
# Credentials (if needed)
username = 'username'
password = 'password'
@Guitsou
Guitsou / usb_auth.md
Last active August 7, 2020 07:53
Authentification avec le PAM USB : se connecter avec une clé USB, et verrouiller la session automatiquement... Tutorial Ubuntu 13.04 / LXDE Sources : http://doc.ubuntu-fr.org/tutoriel/pam-usb /

Installation des paquets

sudo apt-get update && sudo apt-get install libpam-usb pamusb-tools

Il est possible de compiler le paquet pour les distributions n'ayant pas de paquet...

Ajout de clés et utilisateurs

http://blog.xn--hry-bma.com/article9/configurer-un-reverse-proxy-apache-http-https