Skip to content

Instantly share code, notes, and snippets.

@cocoy
cocoy / gist:b9e63d871c3a711e153e
Created April 8, 2015 14:04
lxc web panel centos init script
#!/bin/sh
# chkconfig: 2345 20 80
# description: LXC Web Panel
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Should-Start:
#!/bin/bash -xe
EBS_DEVICE='/dev/sdh'
INSTANCE_ID=$1
AKI=${2:-'aki-5f15f636'}
ARI=${3:-'ari-0915f660'}
ARCH=${4:-'i386'}
SIZE=${5:-10}
AZ=${6:-'us-east-1d'}
NAME=${7:-"ami-from-$INSTANCE_ID"}
0 0 * * * /vol/conf/snapshot.sh >> /mnt/backup_ebs.log 2>&1
0 2 * * * /vol/conf/manage_snaphost.sh >> /mnt/backup_ebs.log 2>&1
@cocoy
cocoy / gist:794683
Created January 25, 2011 08:53
patch to ssh keypair for littlechef
--- a/littlechef.py
+++ b/littlechef.py
@@ -49,6 +49,7 @@ def new_deployment():
print >>authfh, "[userinfo]"
print >>authfh, "user = "
print >>authfh, "password = "
+ print >>authfh, "keypair-file = "
print "auth.cfg file created..."
@cocoy
cocoy / gist:813213
Created February 6, 2011 07:50
check disk space
du -hx --max-depth=1 /var
lsof -n |grep deleted --kill -HUP <pid>
@cocoy
cocoy / gist:838322
Created February 22, 2011 07:07
Check and protect instance for termination:
Check if termination is allowed:
for i in `ec2-describe-instances | grep ^INSTANCE | cut -f2`; do ec2dinatt --disable-api-termination $i ; done
Protect:
for i in `ec2-describe-instances | grep ^INSTANCE | cut -f2`; do ec2minatt --disable-api-termination true $i ; done
@cocoy
cocoy / gist:921226
Created April 15, 2011 06:15
Resize/Increase the Size of a File Based DomU Xen Filesystem
Backup the File based image firstly, making sure it is not mounted nor running as a xen domU.
dd if=/dev/zero of=file.img bs=1M conv=notrunc count=1 seek=2000
#This resizes the file.img to 2GB.
losetup /dev/loop1 file.img
#loop1 had to be used as xen was already running a different domU via loop0.
e2fsck -f /dev/loop1
@cocoy
cocoy / instance-to-ebs-ami.sh
Created June 10, 2011 05:38
instance-to-ebs-ami.sh
#!/bin/bash
# Run this script on the instance to be bundled
# tested with Canonical Ubuntu 9.10 base ami
EBS_DEVICE=${1:-'/dev/sdh'}
IMAGE_DIR=${2:-'/mnt/tmp'}
EBS_MOUNT_POINT=${3:-'/mnt/ebs'}
mkdir -p $EBS_MOUNT_POINT
mkfs.ext3 ${EBS_DEVICE} -L uec-rootfs
#!/bin/bash
#
# Filaneme: ebs_backup
#
VOLUMES=''
EBS_DIR=/nfs-raid
ISMOUNTED=$(df -la | grep -c $EBS_DIR)
if [ $ISMOUNTED -gt 0 ];then
@cocoy
cocoy / gist:1156322
Created August 19, 2011 08:19
s3 public policy
{
"Version":"2008-10-17",
"Id":"",
"Statement":[{
"Sid":"Stmt1313741300912",
"Effect":"Allow",
"Principal":{
"AWS":"*"
},
"Action":"s3:GetObject",