Created
June 20, 2014 23:55
-
-
Save vool/cd48c7bf96af141638bd to your computer and use it in GitHub Desktop.
Bash script for compiling firefox (.xpi) extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Description: Script to generate firefox .xpi extensions | |
## Usage: xpimaker name dir[optional] | |
## Example: ./xpimaker.sh my-extension src | |
## Author: Keith o'Faoláin | |
# check for extension name | |
if [ -z "$1" ] | |
then | |
echo " ERROR - You must provide a name for your extension $(tput sgr 0)" | |
exit | |
else | |
EXTN=$1".xpi" | |
echo "+============================================================>" | |
echo -e "| \033[34m xpimaking ... "$EXTN"$(tput sgr 0)" | |
echo "+============================================================>" | |
# check if path provided | |
if [ -z "$2" ] | |
then | |
DIR=`pwd` | |
echo "| No path provided, using current directory... "$2 | |
else | |
# check if valid path | |
echo "| Checking for path ... "$2 | |
if [ -d "$2" ] | |
then | |
echo "| valid path ..." | |
DIR=$2 | |
else | |
echo -e "| \033[31m path not valid$(tput sgr 0)" | |
exit | |
fi | |
fi | |
fi | |
echo "| ... using path "$DIR | |
# delete old extension if present | |
if [ -f "$EXTN" ] | |
then | |
echo "| deleting old extension ..." | |
rm "$EXTN" | |
fi | |
# zip up your ... | |
echo "| creating extension ..." | |
ORGDIR=`pwd` | |
(cd $DIR; zip -r "$ORGDIR/"$EXTN *) | |
#check | |
if [ -f "$EXTN" ] | |
then | |
echo -e "| \033[32m extension created successfully ...$(tput sgr 0)" | |
else | |
echo -e "| \033[31m ERROR extension not created ...$(tput sgr 0)" | |
exit | |
fi | |
echo "+============================================================>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment