Infos Reseau
1 | IP=$(ip -4 -o a | sed -e '/^2:/!d;s/^.*inet //;s/\/.*$//g') |
Modification des hosts et dns
1 | [[ $(grep -E "$IP(.*)$(hostname -s)(.*)" /etc/hosts) ]] || echo -e "$IP $(hostname -s)" >> /etc/hosts |
Verification execution en root
1 | [[ $(whoami) != root ]] && { echo "ERREUR : Veuillez exécuter ce script en tant que root avec la commande sudo !"; exit 1; } |
Proxy
APT:
1 | echo -e "Acquire::http::Proxy \"${PROXY_URL}/\";" > /etc/apt/apt.conf.d/proxy.conf |
System:
1 | PROXY_URL="http://USER:PASS@HOST:PORT" |
Maven:
1 | mkdir -p ~/.m2 |
Curl:
1 | echo "proxy = ${http_proxy}" > ~/.curlrc |
Decompresser à la volée
1 | curl -s $PACKAGE_REGISTRY/stedolan/jq/1.6/jq-1.6.tar.gz | tar xz -C /usr/bin/ && chmod +x /usr/bin/jq |
Add Iptables
1 | iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT && iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT && iptables-save 2> /dev/null > /etc/sysconfig/iptables |
Optimisation memoire Java (java heap size)
1 | -Xmx2048m -Xms512m -XX:MaxPermSize=2048m -XX:+UseConcMarkSweepGC -XX:ReservedCodeCacheSize=128m -XX:+HeapDumpOnOutOfMemoryError |
Changement de cible binaire
1 | update-alternatives --set php /usr/bin/php5.6 |
Manipulation de variables
1 | Variable avec nom dynamique (shell): |
Sed tricks
1 | change maven version |
Find tricks
1 | find ${builder.buildDir}/ -name "*.sh" -exec chmod +x {} \\; |
Import propre sql
1 | mysql -u root -e "source /db.sql;" |
Windows Startup applications
1 | %AppData%\Microsoft\Windows\Start Menu\Programs\Startup |
Systemd Authorize execution from alternative PATH
1 | semanage fcontext -a -t bin_t "/data/pgsql/bin(/.*)?" |
Tester la presence d’un executable:
1 | command -v <BIN> |
Pousser une commande en Background et la récupérer:
1 | tail -f /dev/null #exemple |