<<'EOF'

Lately I’ve been entranced by Amazon’s EC2 and S3 systems, but it has brought up some good ideas to share here. This one came in handy when writing a shell script to automate installation of Debian in a loopback file mount, and I needed the script to write another script itself. I’ll get around to posting that sometime later, but for now…

#!/bin/sh
# ... other stuff ...
sudo cat > $CHROOTMNT/tmp/chroot.sh <<'CHROOT'
#!/bin/bash
cd /usr/local/
unzip /tmp/ec2-api-tools.zip
ln -s ec2-api-tools* ec2-api-tools
chmod -R a-w /usr/local/ec2-api-tools/
rm /tmp/ec2-api-tools.zip
cat >> /etc/profile <<'EC2APIPROFILE'

export EC2_HOME=/usr/local/ec2-api-tools
export PATH=$PATH:$EC2_HOME/bin
EC2APIPROFILE
# ... other stuff ...
CHROOT
sudo chmod a+x $CHROOTMNT/tmp/chroot.sh
sudo chroot $CHROOTMNT /tmp/chroot.sh

I was having trouble before finding this.

Disabling parameter substitution permits outputting literal text. Generating scripts or even program code is one use for this.

Without disabling parameter substitution, it was expanding "$PATH" to my current $PATH, instead of writing "$PATH" like I wanted. Sure, I could have unset it before running the script, but this is much more useful.

This entry was posted on Thursday, April 26th, 2007 at 7:01 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Be the first to leave a comment.

Leave a Reply