-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
fakeroot/ | ||
sshfail2kml_*_all.deb | ||
sshfail2kml_*_amd64.changes | ||
sshfail2kml-*.rpm | ||
sshfail2kml_*.deb | ||
sshfail2kml_*.changes | ||
sshfail2kml_*.dsc | ||
sshfail2kml_*.tar.gz | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# this is a fast way to create packages with the fpm tool: https://github.com/jordansissel/fpm/wiki | ||
|
||
DIR="$$/" # lets make a random temp dir as a fakeroot | ||
NAME="sshfail2kml" | ||
DESC="SSH failed login attempts logged and GeoIP info acquired for Google Map KML display in an HTML page. Complete with JSON results and SQLite indexed database for a log rotation friendly setup." | ||
URI="https://github.com/BIAndrews/sshfail2kml" | ||
LIC="GPLv3" | ||
PROV="sshfail2kml" | ||
EMAIL="[email protected]" | ||
|
||
################################################################################################# | ||
# | ||
# PREFLIGHT CHECK FOR REQUIRED TOOLS | ||
# | ||
|
@@ -29,18 +42,17 @@ if [ $? -ne 0 ];then | |
|
||
fi | ||
|
||
# juuussttt in case | ||
if [ "$DIR" == "/" ]; then | ||
echo "ERROR: the fakeroot temp dir can't be / or really really bad things will happen." | ||
exit 255; | ||
fi | ||
|
||
######################################################################################## | ||
# | ||
# LETS GO | ||
# | ||
|
||
DIR="fakeroot/" | ||
NAME="sshfail2kml" | ||
DESC="SSH failed login attempts logged and GeoIP info acquired for Google Map KML display in an HTML page. Complete with JSON results and SQLite indexed database for a log rotation friendly setup." | ||
URI="https://github.com/BIAndrews/sshfail2kml" | ||
LIC="GPLv3" | ||
PROV="sshfail2kml" | ||
EMAIL="[email protected]" | ||
|
||
if [ ! -f "${PWD}/version.sh" ];then | ||
echo "Unable to find the version.sh file." | ||
pwd | ||
|
@@ -55,6 +67,10 @@ if [ $? -ne 0 ];then | |
exit 1 | ||
fi | ||
|
||
# | ||
# Lets automatically create the package release number for jenkin/ci automation, resets on a new version/tag | ||
# | ||
|
||
if [ -f "${PWD}/.release-${VER}" ];then | ||
. "${PWD}/.release-${VER}" | ||
RELEASE=$((RELEASE+1)) | ||
|
@@ -63,7 +79,12 @@ RELEASE="0" | |
fi | ||
echo "RELEASE=$RELEASE" > "${PWD}/.release-${VER}" | ||
|
||
echo "Building packages for ${VER}-${RELEASE}" | ||
############################################################### | ||
# | ||
# Create and populate the fakeroot directory to be packaged | ||
# | ||
|
||
echo "Building package fakeroot dir for ${VER}-${RELEASE}" | ||
|
||
install -d $DIR/var/lib/sshfail2kml $DIR/etc/cron.d $DIR/usr/bin | ||
cp -f ../sshfail2kml $DIR/usr/bin | ||
|
@@ -75,35 +96,54 @@ chmod o-rwx $DIR/etc/sshfail2kml.conf | |
echo "DIR: $DIR" | ||
cd $DIR | ||
|
||
################################## | ||
# | ||
# CREATE THE REDHAT PACKAGE | ||
# | ||
# todo - when fpm can make srpms add that | ||
|
||
|
||
fpm \ | ||
--url $URI --license $LIC --provides $PROV -p "../$NAME-$VER-$RELEASE.noarch.rpm" \ | ||
-m $EMAIL --no-rpm-sign -v $VER --iteration $RELEASE -a noarch \ | ||
-s dir -t rpm -n $NAME -d php-cli -d php-pdo --verbose --config-files /etc/sshfail2kml.conf --directories /var/lib/sshfail2kml --description "$DESC" \ | ||
* | ||
|
||
################################## | ||
# | ||
# CREATE THE DEBIAN PACKAGE | ||
# | ||
|
||
fpm \ | ||
--url $URI --license $LIC --provides $PROV -p "../$NAME-$VER-${RELEASE}_all.deb" \ | ||
-m $EMAIL -v $VER --iteration $RELEASE -a all \ | ||
-s dir -t deb -n $NAME -d php5-cli -d php5-sqlite --verbose --config-files /etc/sshfail2kml.conf --directories /var/lib/sshfail2kml --description "$DESC" \ | ||
* | ||
|
||
cd .. | ||
|
||
if [ -f "$NAME-$VER-$RELEASE.noarch.rpm" ];then | ||
rpm -qpil $NAME-$VER-$RELEASE.noarch.rpm | ||
echo "Successfully created redhat package." | ||
|
||
rpm -qpil $NAME-$VER-$RELEASE.noarch.rpm | ||
echo "Successfully created redhat package." | ||
|
||
else | ||
echo "FAILED TO CREATE RPM PACKAGE" | ||
exit 1 | ||
|
||
echo "FAILED TO CREATE RPM PACKAGE" | ||
exit 1 | ||
|
||
fi | ||
|
||
if [ -f "$NAME-$VER-${RELEASE}_all.deb" ];then | ||
echo "Successfully created debian package." | ||
|
||
echo "Successfully created debian package." | ||
|
||
else | ||
echo "FAILED TO CREATE DEBIAN PACKAGE" | ||
exit 1 | ||
|
||
echo "FAILED TO CREATE DEBIAN PACKAGE" | ||
exit 1 | ||
|
||
fi | ||
|
||
#clean up | ||
#clean up, this is a good example of why we never run someone elses code as root | ||
rm -rf $DIR |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# example, external file to work better with CI/CD | ||
VER="1.3.5" | ||
VER="1.3.10" |