Tikejhya: Ashish Nepal

Knowledgebase

Month: September 2013

amazon s3

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

This is simple guide on howto, install and mount s3 into your server.

yum install gcc libstdc++-devel gcc-c++ curl-devel libxml2-devel openssl-devel mailcap make svn

cd /usr/local/src

wget http://sourceforge.net/projects/fuse/files/fuse-2.X/2.9.1/fuse-2.9.1.tar.gz
tar -xzvf fuse-2.9.1.tar.gz

cd fuse-2.9.1 && ./configure --prefix=/usr && make && make install
ldconfig && export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/

modprobe fuse
cd /usr/local/src
svn checkout http://s3fs.googlecode.com/svn/trunk/ s3fs
cd s3fs
autoreconf --install && ./configure --prefix=/usr && make && make install
ldconfig

vi /etc/passwd-s3fs
my-s3-bucket:AccessKeyId:SecretAccessKey
chmod 600 /etc/passwd-s3fs

[create Bucket ¬ [i prefer creating seperate user] ¬ create group and assign policy ¬ ]

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

what is Amazon Resource Name (ARN)?
Check summary of Group.

What is Principal?
Check summary of User.

mkdir -p /aws
s3fs -o allow_other -o use_cache=/tmp mybucket /aws -odefault_acl=public-read

# Check if its mounted or not
mount

df -h
df: `/aws’: Transport endpoint is not connected

If this is behind firewall you will need to open port 80/443 [depending upon what you want to use.]
If not try
fusermount -u /aws

and mount again
fusermount -u /aws
s3fs -o allow_other -o use_cache=/tmp mybucket /aws -odefault_acl=private

###
## fstab (for boot time)
s3fs#bucketname /mountpath fuse use_cache=/tmp,allow_other,uid=user,gid=group 0 0

NOTE, fuse doesnot support dir, and file modes

change ownership recursively

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

find dir -type f -exec chmod 644 {} ‘;’ # make all files rw-r-r-
To change permissions bits of all directories:

find dir -type d -exec chmod 755 {} ‘;’ # make all directories rwxr-xr-x
It would be nice if you could just do this:

sticky bit linux

sticky bit

e.g you want to create a directory called /web
and owned by lighttpd and you want it to be written by lighttpd even if its touched by some other user.

chown -R lighttpd. /web
chown -R lighttpd. *
chmod 775 * -R
chmod +t * -R
chmod u+s,g+s * -R

Bash script to recursively add a file folder inside directory

This is just a sample script which will allow you to create directories inside directory for depth of 3 folders, with a file in each folder in 3rd directory.

ie.
1/2/3
3/4/3 …. and so on.

#!/bin/bash
cd dir
for ((i=0;i<=9;i+=1)); do mkdir -p $i cd $i; touch index.html for ((j=0;j<=9;j+=1)); do mkdir -p $j cd $j; touch index.html for ((k=0;k<=9;k+=1)); do mkdir -p $k; touch index.html done cd ../ done cd ../ done

Taking off one level off, which creats only 2 level

#!/bin/bash
cd dir
for ((i=0;i<=9;i+=1)); do mkdir -p $i cd $i; touch index.html for ((j=0;j<=9;j+=1)); do mkdir -p $j; touch index.html done cd ../ done

Powered by WordPress & Theme by Anders Norén