This file contains hidden or 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 -e | |
# https://gist.github.com/tomfanning/2a69ba71b2371b2e6149b49d43198614 | |
#CREATE TABLE IF NOT EXISTS `smartstats` ( | |
# `id` int(11) NOT NULL AUTO_INCREMENT, | |
# `host` varchar(50) NOT NULL, | |
# `timestamp` datetime NOT NULL, | |
# `diskserial` varchar(50) NOT NULL, | |
# `attribute` tinyint(4) unsigned NOT NULL, |
This file contains hidden or 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
$errorActionPreference='Stop'; | |
remove-item -recurse -force c:\backup\tsl.prev -ErrorAction Ignore | |
rename-item c:\backup\tsl c:\backup\tsl.prev | |
get-vm | where-object -Property Name -like 'tsl.*' | export-vm -path c:\backup\tsl; | |
robocopy C:\backup\TSL \\sg-81-vmhost\usb-backup\TSL *.* /mir |
This file contains hidden or 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 -e | |
# set up a swapfile | |
dd if=/dev/zero of=/1GB.swap bs=1024 count=1048576 | |
mkswap /1GB.swap | |
chmod 0600 /1GB.swap | |
swapon /1GB.swap | |
echo " | |
/1GB.swap none swap sw 0 0" >> /etc/fstab | |
echo " |
This file contains hidden or 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 -e | |
rootpw="mypassword" | |
cat /etc/ssh/sshd_config | sed "s/PasswordAuthentication no/PasswordAuthentication yes/" | sed "s/#PermitRootLogin yes/PermitRootLogin yes/" > /etc/ssh/sshd_config | |
echo " | |
MaxAuthTries 10" >> /etc/ssh/sshd_config | |
systemctl restart sshd | |
echo root:$rootpw | chpasswd |
This file contains hidden or 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
zfs create -o volblocksize=32k -V 10G tslpool/iscsi1 | |
zfs set sync=disabled tslpool/iscsi1 | |
targetcli | |
block/ create name=block_backend dev=/dev/zvol/tslpool/iscsi1 | |
cd /iscsi | |
create iqn.2017-11.com.mydomain.ad.zfstest:iscsidisk1 | |
cd /iscsi/iqn.2017-11.com.mydomain.ad.zfstest:iscsidisk1/tpg1/acls | |
# create acl with the initiator (client) name here, not the one you just created | |
create iqn.1991-05.com.microsoft:dc1.ad.mydomain.com | |
cd iqn.1991-05.com.microsoft:dc1.ad.mydomain.com |
This file contains hidden or 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
function Send-Glip { | |
$msg = $args[0].Replace("`"", "\`"") | |
$body='{"body":"' + $msg + '"}' | |
iwr https://hooks.glip.com/webhook/webhook-guid-here -method post -ContentType application/json -body $body > out-null | |
} | |
# Usage: | |
# send-glip "Message to send" |
This file contains hidden or 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
In userdata on the target: | |
<powershell> | |
$admin = [adsi]("WinNT://./administrator, user") | |
$admin.PSBase.Invoke("SetPassword", "SufficientlyC0mplexPasswordHere!") | |
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('https://gist.githubusercontent.com/tomfanning/19a983ad793e63d68117bd90bd57e02b/raw/8508a56fd5eb0456e2aa34a278cb7e6fbafe9dd8/configure-windows-remoting-ec2.ps1')) | |
</powershell> | |
Also ensure a security group is applied which opens port 5986. |
This file contains hidden or 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
#Requires -Version 3.0 | |
# Configure a Windows host for remote management with Ansible | |
# ----------------------------------------------------------- | |
# | |
# This script checks the current WinRM (PS Remoting) configuration and makes | |
# the necessary changes to allow Ansible to connect, authenticate and | |
# execute PowerShell commands. | |
# | |
# All events are logged to the Windows EventLog, useful for unattended runs. |
This file contains hidden or 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
From cmd.exe: | |
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" | |
choco install mls-software-openssh -y | |
If your pageant offers lots of SSH keys, you will get an error "too many authentication failures" | |
To overcome, in C:\Program Files\OpenSSH\etc\sshd_config, set: | |
MaxAuthTries 10 | |
restart OpenSSHd service |
This file contains hidden or 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
# unproven as yet | |
# initial backup | |
zfs snapshot -r tank1@backup | |
zfs send -R tank1@backup | zfs receive -vF usb5tb | |
# incrementals | |
# it is optional to delete snapshots - in which case just create a snapshot with name base on time. | |
zfs rename -r tank1@backup tank1@previous_backup # rename the "old" snapshot |