Skip to content

Instantly share code, notes, and snippets.

@toshihirock
toshihirock / setPassword.sh
Created February 23, 2015 14:06
パスワードの一括設定
sudo chpasswd <<EOT
user1:password1
user2:password2
EOT
#!/bin/bash -ex
# lanch
instance_id=`aws ec2 run-instances --image-id ami-hoge --instance-type t2.micro --subnet-id subnet-hoge --security-group-ids sg-hoge --key-name hogekey |jq -r '.Instances[].InstanceId'`
echo "instance_id = ${instance_id}"
sleep 5
# add tag
aws ec2 create-tags --resources ${instance_id} --tags Key=Name,Value=my-host-name
require "selenium-webdriver"
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://www.google.co.jp"
element = driver.find_element(:name, 'q')
element.send_keys "selenium"
element.submit
puts driver.title
WAPFILENAME=/swap.img
MEMSIZE=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
if [ $MEMSIZE -lt 2097152 ]; then
SIZE=$(($MEMSIZE * 2))k
elif [ $MEMSIZE -lt 8388608 ]; then
SIZE=${MEMSIZE}k
elif [ $MEMSIZE -lt 67108864 ]; then
SIZE=$(($MEMSIZE / 2))k
else
# *.deb or *.sh
find . -type f -name "*.deb" -or -name "*.sh"
# not *.deb or *.sh
find . -type f ! -name "*.deb" -and ! -name "*.sh"
# date format(hoge_20150307 etc...)
find . -type f -name "*`date +%Y%m%d`"
#!/bin/bash
dir=/etc/crontab
echo -e "\n**************${dir}****************"
cat ${dir}
echo "***********************************"
for dir in `ls -d /var/spool/cron/*`
do
echo -e "\n**************${dir}****************"
# valid
aws cloudformation validate-template --template-body file://MyStack.json
# create stack
aws cloudformation create-stack --template-body file://Mystack.json --stack-name MyFirstStack
# create stack with parameter
aws cloudformation create-stack --template-body file://CloufFormationSample.json --stack-name MyFirstStack --parameters ParameterKey=KeyNameParameter,ParameterValue=HogeKeyPair
# update stack
# dry run
logrotate -d /etc/logrotate.conf
# specific conf
logrotate -d /etc/logrotate.d/httpd
# force execute(Normally logrotate confirms /var/lib/logrotate.status)
logrotate -f /etc/logrotate.conf
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "A simple stack that launches an instance.",
"Parameters" : {
"InstanceTypeParameter" : {
"Type" : "String",
"Default" : "t2.micro"
},
"KeyNameParameter" : {
"Type" : "String"
module Hoge
def filter_record
puts "hoge hello"
end
end
module Fuga
include Hoge
def filter_record