Skip to content

Instantly share code, notes, and snippets.

@skunkie
skunkie / reposync.sh
Last active December 3, 2017 00:12
This bash script synchronizes local repositories with external repositories, RPM, reposync, createrepo
#!/bin/bash
# requires bash version 4
# This script synchronizes local repositories with
# external repositories
#
############################################################
# PREREQUISITES
############################################################
for util in reposync createrepo; do
@skunkie
skunkie / fileinfo.vbs
Last active November 26, 2015 17:11
VBS script for Check_MK check fileinfo
Option Explicit
Dim config, configFile, f, ffilename, filename, fmtime, fso, mtime, tzo, N, Y, M, D
Set fso = CreateObject("Scripting.FileSystemObject")
configFile = fso.GetParentFolderName(fso.GetParentFolderName(Wscript.ScriptFullName)) & "\fileinfo.cfg"
If NOT fso.FileExists(configFile) Then
WScript.Quit
End If
@skunkie
skunkie / rename_vm.sh
Created December 19, 2014 13:26
Shell script to rename a virtual machine in VMware ESXi
#!/bin/sh
# shell script to rename a virtual machine in ESXi
VOLNAME=$1
DIRNAME=$2
OLDNAME=$3
NEWNAME=$4
VM_DIRPATH="/vmfs/volumes/$VOLNAME/$DIRNAME"
f_OK() {
[settings]
reposroot="/repo"
proxy="http://127.0.0.1:3128"
### EXAMPLE REPO CONFIG ###
# [reposlist]
# epel=true ### use reposync and createrepo
# centos-base=false ### use only createrepo
# vmtools="/opt/scripts/vmtools_osp_sync.sh" ### use a custom command
@skunkie
skunkie / nonascii.sh
Created October 14, 2015 12:22
find non-ASCII characters in a string
#!/bin/sh
usage(){
echo "
find non-ASCII characters in a string
Usage: $0 STRING
"
exit 0
}
@skunkie
skunkie / SetStaticIPtoCMD.ps1
Created March 13, 2018 09:03
Wrap a PowerShell script into BAT/CMD file
# 1. Remove lines containing only comments and empty lines
# 2. Remove a comment after some code, e.g. some code # a comment
# 3. Join a line with a trailing { to the next line, e.g. if (a condition) {$
# 4. Join a line beginning with a } character to the previous line, e.g. ^}$, or ^ }
# 5. Replace the character ` when it is used to break code in two lines, with a space, e.g. somecode `$
# 6. Replace all \r\n (carriage return and new line characters) with '; '
$text = (Get-Content -Path .\SetStaticIP.ps1 | Where-Object {$_ -notmatch "^\s*?#|^$"} | ForEach-Object {$_.Trim()} | Out-String) `
-replace '\s*?#.*?\r\n', '' `
-replace '{\s*?\r\n\s*?', '{' `
@skunkie
skunkie / SetStaticIP.ps1
Last active April 24, 2018 10:48
Set static IP address from DHCP
$addressFamily = 'IPv4'
# Retrieve the network adapter
$adapters = Get-NetAdapter | Where-Object {$_.Status -eq 'Up'}
foreach ($adapter in $adapters) {
$ipConfiguration = $adapter | Get-NetIPConfiguration
if ($ipConfiguration.NetIPv4Interface.DHCP -eq 'Disabled') {
continue # 'DHCP is not enabled'
}
$dns = ($ipConfiguration | Get-DnsClientServerAddress -AddressFamily $addressFamily).ServerAddresses
# Remove any existing IPv4 IP and gateway from the adapter
@skunkie
skunkie / glpi_import_from_vc.pl
Last active June 17, 2022 08:38
Automatic collection of info from vCenter, to GLPI
#!/usr/bin/perl -w
#
# This tool can be used to push inventory of virtual machines and ESXi hosts from a VIServer in GLPI via FusionInventory plugin
use v5.10;
use strict;
use warnings;
use VMware::VIRuntime;
use POSIX 'ceil';
#Requires -Version 3.0
<#
.SYNOPSIS
Log Archiver for Windows
.DESCRIPTION
This script can be used to archive old log files
.PARAMETER Path
The path to the directory with log files.
.PARAMETER ArchiveDays
@skunkie
skunkie / routing.py
Created June 28, 2018 10:08
This script adds rules to the routing policy database
#!/usr/bin/env python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#
# This script adds rules to the routing policy database
#
import ConfigParser
import os
import socket
import sys
from pyroute2 import IPRoute