Skip to content

Instantly share code, notes, and snippets.

@rbobillot
Last active November 2, 2016 19:07
Show Gist options
  • Save rbobillot/d0fc4c01cf9ad174d63516ad48187320 to your computer and use it in GitHub Desktop.
Save rbobillot/d0fc4c01cf9ad174d63516ad48187320 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ $# == 1 ]]
then
if [[ -f $1 ]]
then
TEMPLATE_b64='IyEvYmluL3NoCgpNWVNFTEY9YHdoaWNoICIkMCIgMj4vZGV2L251bGxgClsgJD8gLWd0IDAgLWEgLWYgIiQwIiBdICYmIE1ZU0VMRj0iLi8kMCIKamF2YT1qYXZhCmlmIHRlc3QgLW4gIiRKQVZBX0hPTUUiOyB0aGVuCiAgICBqYXZhPSIkSkFWQV9IT01FL2Jpbi9qYXZhIgpmaQpleGVjICIkamF2YSIgJGphdmFfYXJncyAtamFyICRNWVNFTEYgIiRAIgoK'
jar_file=$1
exec_file=$(basename `echo $jar_file | rev | cut -d '.' -f2 | rev`)
echo $TEMPLATE_b64 | base64 --decode > $exec_file && cat $1 >> $exec_file && chmod +x $exec_file
echo -e "$jar_file: \e[92mFile conerted to\e[0m: $exec_file"
else
echo "Error: $1: No such file or directory"
fi
else
echo "usage: `basename $0` <file_to_convert>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment