Changes

From Genome Analysis Wiki
Jump to navigationJump to search
Line 140: Line 140:  
<code>
 
<code>
 
ubuntu@ip-10-254-60-210:~$ sudo more /etc/rc.local
 
ubuntu@ip-10-254-60-210:~$ sudo more /etc/rc.local
  #!/bin/sh  
+
#!/bin/sh  
  USER=ubuntu
+
#
  THOUSANDG=/mnt/1000g
+
# rc.local
  FILES3=passwd-s3fs
+
#
  S3ERR=/tmp/s3fs.err
+
# This script is executed at the end of each multiuser runlevel.
   
+
# Make sure that the script will "exit 0" on success or any other
   #    Set up for GotCloud   Assumes /dev/xvdf has reference files for GotCloud
+
# value on error.
   mkdir -p /gotcloud
+
#
   mount /dev/xvdf /gotcloud
+
# In order to enable or disable this script just change the execution
   if [ ! -d /gotcloud/gotcloud.ref ]; then
+
# bits.
 +
#
 +
# By default this script does nothing.
 +
USER=ubuntu
 +
THOUSANDG=/mnt/1000g
 +
FILES3=/etc/passwd-s3fs     # Where s3fs access info will live
 +
S3ERR=/tmp/s3fs.err
 +
#  These are needed for s3fs access
 +
AWSACCESSKEYID=AKIAxxxxxxZ3YCZF2Q
 +
AWSSECRETACCESSKEY=ft1eJa3WxxxxxxxNlbA08x/G8iMqkMIkJjFCIGf
 +
 
 +
 
 +
#    Check that we have swap set up
 +
a=`swapon -s | grep -v File`
 +
if [ "$a" = "" ]; then
 +
  echo "#######################################################"
 +
  echo "#  You have no SWAP file set up"
 +
  echo ""
 +
  echo "# swap=/mnt/swapfile"
 +
  echo "#  sudo dd if=/dev/zero of=$swap bs=1073741824 count=20"
 +
  echo "#  sudo chown root:root $swap"
 +
  echo "#  sudo mkswap $swap"
 +
  echo "#  sudo chmod 0600 $swap"
 +
  echo "#  sudo swapon $swap"
 +
  echo ""
 +
  echo "#  If need be, add to /etc/fstab"
 +
  echo "#  echo "$swap  none swap sw  0  0" >> /etc/fstab"
 +
   echo "#######################################################"
 +
fi
 +
 
 +
#    Set up for GotCloud
 +
gc=/gotcloud.mnt
 +
if [ ! -r $gc/release_version.txt ]; then
 +
   mkdir -p $gc
 +
   mount /dev/xvdg $gc
 +
   if [ -d $gc/gotcloud.ref ]; then
 
     echo "#######################################################"
 
     echo "#######################################################"
     echo "#  GotCloud is not set up on /gotcloud"
+
     echo "#  GotCloud is set up on $gc"
 
     echo "#######################################################"
 
     echo "#######################################################"
 
   fi
 
   fi
+
fi
  #    Setup 1000g access by s3fs
+
 
  usermod -aG fuse $USER
+
#    Set up access to S3 storage as normal filesystem
  echo 'AKIAIW5TQEUWZ3YCZF2Q:ft1eJa3WGzNE8iitNlbA08x/G8iMqkMIkJjFCIGf' > /etc/$FILES3
+
echo "${AWSACCESSKEYID}:$AWSSECRETACCESSKEY" > $FILES3
  chown root.root /etc/$FILES3
+
chown root.root $FILES3
  chmod 640 /etc/$FILES3
+
chmod 640 $FILES3
  mkdir -p $THOUSANDG
+
 
 +
usermod -aG fuse $USER
 +
 
 +
#    Setup 1000genomes
 +
mkdir -p $THOUSANDG
 +
if [ ! -r $THOUSANDG/release ]; then
 
   chown $USER.$USER $THOUSANDG
 
   chown $USER.$USER $THOUSANDG
  #  It is tempting to use caching with  -o use_cache=/tmp 1000genomes
  −
  #  But s3fs cache is exceedingly dumb and does not use a least recently used
  −
  #  mechanism -- which will guarantee your root volume will fill up
   
   /usr/local/bin/s3fs -o allow_other 1000genomes $THOUSANDG > $S3ERR 2>&1
 
   /usr/local/bin/s3fs -o allow_other 1000genomes $THOUSANDG > $S3ERR 2>&1
 
   if [ ! -r $THOUSANDG/alignment.index ]; then
 
   if [ ! -r $THOUSANDG/alignment.index ]; then
    echo "#######################################################" >> $S3ERR
  −
    echo "#  1000genomes is not set up on $THOUSANDG" >> $S3ERR
  −
    echo "#######################################################" >> $S3ERR
  −
  fi
  −
  df -h
  −
  −
  #  Make sure we have a swap file
  −
  a=`swapon -s | grep -v Filename'
  −
  if [ "$a" = "" ]; then
   
     echo "#######################################################"
 
     echo "#######################################################"
     echo "#  You have no SWAP file set up"
+
     echo "#  1000genomes is not set up on $THOUSANDG"
    echo "#"
+
     echo "#   See S3FS errors in $S3ERR"
    echo "#  swap=/mnt/swapfile"
  −
    echo "#  sudo dd if=/dev/zero of=$swap bs=1073741824 count=20"
  −
     echo "# sudo chown root:root $swap"
  −
    echo "#  sudo mkswap $swap"
  −
    echo "#  sudo chmod 0600 $swap"
  −
    echo "#  sudo swapon $swap"
  −
    echo "#"
  −
    echo "#  If need be, add to /etc/fstab"
  −
    echo "#  echo "$swap  none swap sw  0  0" >> /etc/fstab"
   
     echo "#######################################################"
 
     echo "#######################################################"
 
   fi
 
   fi
 +
  df -h
 +
fi
 +
exit 0
   −
  exit 0
   
</code>
 
</code>
  
283

edits

Navigation menu