Outils pour utilisateurs

Outils du site


blog

Cobbler déploiement Debian

Debian

mount /home/debian-8.7.1-amd64-DVD-1.iso /mnt/iso
cobbler import --name=debian --path=/mnt/iso --breed=debian --os-version=jessie --arch=x86_64
 
cobbler sync
 
cobbler profile copy --name=debian-x86_64 --newname=debian-x86_64_custom
cobbler profile edit --name debian-x86_64_custom --virt-type=kvm --virt-bridge=virbr0 \
	--kopts="debian-installer/allow_unauthenticated=true console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 ipv6.disable=1 vga=0x317" \
	--kopts-post="console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 ipv6.disable=1 vga=0x317" \
	--virt-file-size=30 --virt-ram=2048
cobbler system add --profile=debian-x86_64_custom --name=debtest1 --mac=52:54:00:DD:EE:FF --interface=eth0 --virt-type=kvm #--virt-file-size=30 --virt-ram=2048
 
cd 
wget http://ftp.fr.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/netboot.tar.gz
cd  /var/www/cobbler/links/debian-x86_64/install/
mkdir netboot
cd netbook
tar xvf ~/netboot.tar.gz

/var/www/cobbler/links/debian-x86_64/.treeinfo

[general]
family = Debian
timestamp = 1272326522.13
totaldiscs = 1
version = 8
discnum = 1
packagedir = dists
arch = x86_64
 
[images-x86_64]
kernel = install/netboot/debian-installer/amd64/linux
initrd = install/netboot/debian-installer/amd64/initrd.gz
cobbler repo copy --name=debian-x86_64 --newname=debian-x86_64_custom
cobbler repo edit --name=debian-x86_64_custom --mirror=http://192.168.21.1/debian8/dists/jessie 
KVM
export COBBLER_SERVER=192.168.21.3
LANG=C koan --virt --wait=-1 --system=debtest1 --server=192.168.21.3

Clean

cobbler system remove --name debtest1
 
cobbler profile remove --name debian-x86_64_custom  
cobbler profile remove --name debian-x86_64
cobbler profile remove --name debian-gtk-x86_64
 
cobbler distro remove --name debian-x86_64_custom
cobbler distro remove --name debian-x86_64
cobbler distro remove --name debian-gtk-x86_64
 
cobbler repo remove --name debian-x86_64_custom
cobbler repo remove --name debian-x86_64
cobbler repo remove --name debian-gtk-x86_64
2025/03/24 15:06

CMS PHP Wordpress

Source : https://codex.wordpress.org/Debugging_in_WordPress

Debug Wordpress

wp-config.php

 // Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
 
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
 
// Disable display of errors and warnings 
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
 
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );

Sécurité

Scan
sudo apt-get install ruby-rubygems ruby-dev
export PATH="$PATH":/home/jibe/.local/share/gem/ruby/3.0.0/bin
gem install --user-install wpscan
wpscan --url https://wp.acme.fr -o wpscan_wp.acme.fr.txt
2025/03/24 15:06

Doublon avec scriptinitsysvroot

Script init Wrapper

Lancement du serveur BCM sous un compte utilisateur (non-root) sous Debian.

1) Création d’un nouvel utilisateur dédie au serveur BCM.

Dans notre exemple il s’agit de « bcm »

TODO Commande de création utilisateur système

2) Création du script /etc/init.d/BMC

/etc/init.d/BMC

#! /bin/bash
 
# chkconfig: 35 85 15
# description: Startup script for BMC Client Management agent
 
### BEGIN INIT INFO
# Provides:          BMC
# Required-Start:    $network $local_fs $remote_fs $time $syslog
# Required-Stop:     $network $local_fs $remote_fs $time $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Wrapper pour lancer les scripts sysVinit avec un compte utilisateur (non root)
# Description:       Wrapper pour lancer les scripts sysVinit avec un compte utilisateur (non root)
### END INIT INFO
 
BCM_USER=bcm
BCM_INITSCRIPT=/etc/init.d/BMCClientManagementAgent
 
su - $BCM_USER -c "$BCM_INITSCRIPT" "$@"

Note : Les commentaires du scripts sont nécessaire. Voir

3) Gestion des services

Placer les droits d’exec :

chmod +x /etc/init.d/BMC

Désactivation du démarrage de l’ancien script.

update-rc.d BMCClientManagementAgent remove

Activation du nouveau script

update-rc.d BMC defaults

On vérifie :

find /etc/rc* -iname "*bmc*"
4) Fin

Arrêt process lancé en root /etc/init.d/BMCClientManagementAgent stop

Ici l’utilisateur « bcm » devient le nouveau propriétaires des fichiers

chown bcm: /opt/bcm/ -R

On démarre BCM

/etc/init.d/BCM start
En cas de Pb

Refaire point 3 et 4. Idem si application patch.

NB : il convient dans la supervision de s’assurer que le process tourne sous le bon compte. Exemple :

pgrep -u bcm mtxagent && echo OK || echo NOK

2025/03/24 15:06

Script HA supersivion Nagios routeur actif par SNMP

check_snmp_active_router.sh

#! /bin/bash
 
# Creative Commons CC0 Public Domain Licence
 
set -euo pipefail
IFS=$' \t\n'
export LC_ALL=C
 
OID_HOSTNAME=.1.3.6.1.2.1.1.5.0
LABEL="ACTIVE_ROUTER"
 
ALL_ARGS=("$@")
 
exec 6>&1 # Link file descriptor #6 with stdout. Saves stdout.
 
# FIX IGNORED ~/.snmp/snmp.conf WHEN 'sudo -u nagios check_snmp_host.sh'
HOME=$(getent passwd "$(whoami)" | cut -d: -f6)
 
PATH="/sbin:/usr/sbin:$PATH"
 
exit_malfunction() {
	exec 1>&6 6>&- # Restore stdout and close file descriptor #6
	echo "${LABEL} ${STATUS_MSG} - ERROR $*"
	exit 3
}
 
# NAGIOS EXIT STATUS
# STATE_OK=0 ; STATE_WARNING=1 ; STATE_CRITICAL=2 ; STATE_UNKNOWN=3; STATE_DEPENDENT=4
STATUS_MSG=UNKNOWN
typeset -i STATUS_CODE=3
trap 'if [ $STATUS_CODE -eq 3 ] && [ $? -ne 0 ] ; then
  exit_malfunction "Unexpected error"
fi' EXIT ERR
 
command_exists() {
	command -v "$1" >/dev/null 2>&1 || (
		exit_malfunction "I require $1 but it's not installed. Aborting."
	)
}
 
command_exists snmpget
 
get_defaultgw() {
	ip -4 route show default | awk '/^default/ { print $3 }' || exit_malfunction "Can't get default gateway"
}
 
get_hostname() {
	local REMOTE_HOST=$1
	ROUTER_NAME=$(snmpget -r 2 "${ALL_ARGS[@]}" "$REMOTE_HOST" "${OID_HOSTNAME}" | cut -d= -f2 | cut -d: -f2 | xargs) || exit_malfunction "SNMP failed"
}
 
main() {
	local DEFAULTGW
	local -i ROUTER_NB
	DEFAULTGW=$(get_defaultgw)
	get_hostname "$DEFAULTGW"
	ROUTER_NB=$(echo "$ROUTER_NAME" | grep -o -e '[0-9]\+$') || exit_malfunction "Hostname error in '$ROUTER_NAME' for $DEFAULTGW"
	if [ "$ROUTER_NB" -eq 1 ]; then
		STATUS_CODE=0
		STATUS_MSG=OK
	elif [ "$ROUTER_NB" -eq 2 ]; then
		STATUS_CODE=1
		STATUS_MSG=WARNING
	else
		STATUS_CODE=2
		STATUS_MSG=CRITICAL
	fi
	echo "${LABEL} ${STATUS_MSG} - $ROUTER_NAME is active router"
 
}
 
main
exit $STATUS_CODE

FIXME

2025/03/24 15:06

Script en C

Tester un bout de code c sans le compiler grâce à TCC

sudo  apt-get install tcc

hello.c

#! /usr/bin/tcc -run
#include<stdio.h>
 
int main(void)
{
        puts("Hello world !");
        return 0;
}
chmod +x hello.c
./hello.c
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki