This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SFTP_USERS="./sftp_users.txt" | |
cat ${SFTP_USERS} | while IFS='' read -r LINE || [[ -n "$LINE" ]] | |
do | |
ID=`echo $LINE|cut -d: -f1` | |
PASSWORD=`echo $LINE|cut -d: -f2` | |
NEWUID=`echo $LINE|cut -d: -f3` | |
NEWGID=`echo $LINE|cut -d: -f4` | |
if ! id -u ${ID} > /dev/null 2>&1; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sample using a filter to run a command in the container: | |
docker exec `docker ps -q --filter name=frosty_goldberg` /bin/echo Hello | |
Start the container with a label: | |
docker run --label="the_label" -td ubuntu | |
Use the label to identify the container and run a command in it: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Yes, you have Ruby!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getIOWait | |
command_to_run = %Q[iostat 15 2 | awk 'BEGIN{RS=ORS="\\n\\n";FS=OFS="\\n"}/avg-cpu:/' | tail -2 | head -1 | awk {'print $4'}] | |
result = `#{command_to_run}` | |
# result = '20.0' | |
result.to_f | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'timeout' | |
def is_port_open?(ip, port) | |
begin | |
Timeout::timeout(1) do | |
begin | |
s = TCPSocket.new(ip, port) | |
s.close | |
return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'timeout' | |
def is_port_open?(ip, port) | |
begin | |
Timeout::timeout(1) do | |
begin | |
s = TCPSocket.new(ip, port) | |
s.close | |
return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import json | |
from pprint import pprint | |
with open('/0config/network.json') as json_data: | |
d = json.load(json_data) | |
myNetworkInfo = d["networkInfo"] | |
# pprint(myNetworkInfo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$values = ['aaa', 'bbb', 'ccc', 'ddd'] | |
$values.each | String $value | { | |
notify { $value: | |
message => "Value is ${value}" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$file_mode = $facts['os']['family'] ? { | |
'Debian' => '0600', | |
'RedHat' => '0655', | |
default => '0700', | |
} | |
file { '/tmp/test_mode.txt': | |
ensure => file, | |
mode => $file_mode, | |
owner => 'root', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group { 'file_group': | |
ensure => present, | |
} | |
user { 'file_user': | |
ensure => present, | |
gid => 'file_group', | |
} | |
file { '/tmp/my_files': |
OlderNewer