Skip to content

Instantly share code, notes, and snippets.

@ktnyt
Last active October 14, 2015 05:23
Show Gist options
  • Save ktnyt/74b6d8732be115cb5853 to your computer and use it in GitHub Desktop.
Save ktnyt/74b6d8732be115cb5853 to your computer and use it in GitHub Desktop.
Self explanatory
#!/bin/sh
if [ -d treasure_hunt ]
then
rm -r treasure_hunt
fi
mkdir treasure_hunt
echo 'Aye aye mate! Welcome to the treasure hunt!' >> treasure_hunt/README
echo 'Find the keys from each island to open the treasure box!' >> treasure_hunt/README
echo 'First collect the keys here.' >> treasure_hunt/README
echo 'Then put them all in a single file named `key`' >> treasure_hunt/README
echo 'Run `sh treasure_box.sh to test your fate!`' >> treasure_hunt/README
mkdir treasure_hunt/island{A,B,C,D}
mkdir treasure_hunt/island{A,B,C,D}/region{0,1,2,3}
mkdir treasure_hunt/island{A,B,C,D}/region{0,1,2,3}/area{0,1,2,3}
touch treasure_hunt/island{A,B,C,D}/region{0,1,2,3}/area{0,1,2,3}/junk
echo 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' > treasure_hunt/keyA
echo 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' > treasure_hunt/keyB
echo 'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.' > treasure_hunt/keyC
echo 'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' > treasure_hunt/keyD
cat treasure_hunt/key{A,B,C,D} > treasure_hunt/.hidden_key
for ID in {A,B,C,D}
do
DIR=treasure_hunt/island${ID}/region$((RANDOM % 4))/area$((RANDOM % 4))
rm ${DIR}/junk
mv treasure_hunt/key${ID} ${DIR}
done
echo '#!/bin/sh' >> treasure_hunt/treasure_box.sh
echo 'if [ ! -e key ]' >> treasure_hunt/treasure_box.sh
echo 'then' >> treasure_hunt/treasure_box.sh
echo ' echo Find the key first mate!' >> treasure_hunt/treasure_box.sh
echo ' exit' >> treasure_hunt/treasure_box.sh
echo 'fi' >> treasure_hunt/treasure_box.sh
echo 'DIFF=$(diff key .hidden_key)' >> treasure_hunt/treasure_box.sh
echo 'if [ "$DIFF" ]' >> treasure_hunt/treasure_box.sh
echo 'then' >> treasure_hunt/treasure_box.sh
echo ' echo You have failed to open the treasure box.' >> treasure_hunt/treasure_box.sh
echo 'else' >> treasure_hunt/treasure_box.sh
echo ' echo You have successfully opened the treasure box!!' >> treasure_hunt/treasure_box.sh
echo 'fi' >> treasure_hunt/treasure_box.sh
echo 'Ready to go hunting! `cd treasure_hunt` to get started!'
echo 'Some hints are in the README file so try `cat README` or `less README`.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment