Skip to content

Commit

Permalink
Merge branch 'apptuit-master' of https://github.com/ApptuitAI/xcollector
Browse files Browse the repository at this point in the history
 into apptuit-master
  • Loading branch information
rshivane committed Apr 12, 2018
2 parents 518e3d7 + 96b43cf commit 9dc8cd0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
26 changes: 23 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,31 @@ python:
- "3.5"
- "3.6"

cache:
directories:
- '$HOME/.rpmlint/'

before_install:
- |
wget -O ~/.rpmlint/rpmlint-1.9.tar.gz https://github.com/rpm-software-management/rpmlint/archive/rpmlint-1.9.tar.gz;
tar xvfz ~/.rpmlint/rpmlint-1.9.tar.gz -C ~/.rpmlint;
BUILDER=$USER sudo make install -C ~$BUILDER/.rpmlint/rpmlint-rpmlint-1.9
install:
- sudo apt-get -qq update
- sudo apt-get install -y rpm
- sudo apt-get install -y rpm python-rpm
- sudo apt-get install -y lintian
# - sudo apt-get install -y rpmlint
- if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then pip install pylint; fi
- pip install ordereddict pyyaml mysqlclient

before_script:
- if [[ "$TRAVIS_PYTHON_VERSION" = "2.7" ]]; then export IS_PRIMARY_MATRIX_JOB=true; fi
- if [[ $TRAVIS_TAG == apptuit-v* ]]; then export PACKAGE_VERSION=${TRAVIS_TAG#apptuit-v}; fi
- echo $TRAVIS_TAG
- echo $PACKAGE_VERSION
- echo $IS_PRIMARY_MATRIX_JOB

script:
- python -c "import sys; print('python version:%s' % sys.version);"
Expand All @@ -26,6 +41,9 @@ script:
- make -C rpm
- make -C deb

after_success:
- make lint -C rpm
- make lint -C deb

before_deploy:
- PACKAGE_DATE=$(git log -1 --pretty="format:%ad" $TRAVIS_TAG --date=short);
Expand All @@ -37,16 +55,18 @@ before_deploy:

deploy:
- provider: bintray
skip_cleanup: true
file: "deb/bintray-descriptor.json"
user: "$BINTRAY_USER"
key: "$BINTRAY_API_KEY"
on:
tags: true
condition: $PACKAGE_VERSION != "" && $TRAVIS_PYTHON_VERSION == "2.7" && $BINTRAY_API_KEY != ""
condition: $PACKAGE_VERSION != "" && $IS_PRIMARY_MATRIX_JOB == "true" && $BINTRAY_API_KEY != ""
- provider: bintray
skip_cleanup: true
file: "rpm/bintray-descriptor.json"
user: "$BINTRAY_USER"
key: "$BINTRAY_API_KEY"
on:
tags: true
condition: $PACKAGE_VERSION != "" && $TRAVIS_PYTHON_VERSION == "2.7" && $BINTRAY_API_KEY != ""
condition: $PACKAGE_VERSION != "" && $IS_PRIMARY_MATRIX_JOB == "true" && $BINTRAY_API_KEY != ""
Empty file removed deb/DEBIAN/preinst
Empty file.
3 changes: 3 additions & 0 deletions deb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ deb:
cd build; find . -type f ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums
dpkg-deb -b build dist/$(DEB)

lint:
lintian --no-tag-display-limit dist/$(DEB)

clean:
rm -rf build dist

Expand Down
13 changes: 9 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -eE

function setup_log () {
logfile="xcollector-install.log"
Expand Down Expand Up @@ -135,14 +135,18 @@ function post_complete () {
print_message "success" "Installation completed successfully\n"
}

function post_error () {
print_message "error" "Installation failed\n"
}

function check_time_diff () {
print_message "Verifying time offset\n"

local server_header=""
if [ $(command -v curl) ]; then
server_header=$(curl -s --head https://www.google.com/humans.txt | grep '^\s*Date:\s*' | sed 's/\s*Date:\s*//g')
server_header=$(curl -s --head https://www.google.com/humans.txt | grep -i '^\s*Date:\s*' | sed 's/\s*Date:\s*//Ig')
elif [ $(command -v wget) ]; then
server_header=$(wget -S --spider https://www.google.com/humans.txt 2>&1 | grep '^\s*Date:\s*' | sed 's/\s*Date:\s*//g')
server_header=$(wget -S --spider https://www.google.com/humans.txt 2>&1 | grep -i '^\s*Date:\s*' | sed 's/\s*Date:\s*//Ig')
fi

if [ "$server_header" == "" ]; then
Expand All @@ -157,10 +161,11 @@ Please verify that the local server time is accurate manually.\n"

if [ $time_delta -ge 300 -o $time_delta -le -300 ]; then
print_message "warn" "There is too much time difference between local time and Apptuit.
Metrics might now show up in the correct time window when you query\n"
Metrics might not show up in the correct time window when you query\n"
fi
}

trap post_error ERR
setup_log

if [ -n "$XC_ACCESS_TOKEN" ]; then
Expand Down
3 changes: 3 additions & 0 deletions rpm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ rpm:
rpmbuild --define "_topdir %(pwd)/build" -bb build/xcollector-t.spec
if test -f build/RPMS/$(RPM_TARGET)/$(RPM); then mv build/RPMS/$(RPM_TARGET)/$(RPM) ./dist/; else mv xcollector.$(RPM_TARGET).rpm $(RPM); fi

lint:
rpmlint dist/$(RPM)

clean:
rm -rf build dist

Expand Down
3 changes: 3 additions & 0 deletions rpm/xcollector.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ License: LGPLv3+
Summary: XCollector - Data collection agent for apptuit.ai
URL: http://apptuit.ai/xcollector.html
Provides: xcollector = @PACKAGE_VERSION@-@RPM_REVISION@_@GIT_SHORTSHA1@
Packager: XCollector Maintainers <hello+xcollector@apptuit.ai>
Requires: initscripts
Requires: python(abi) >= @PYTHON_VERSION@
Requires: python-devel
Requires: MySQL-python
Expand Down Expand Up @@ -186,6 +188,7 @@ chown -R $XCOLLECTOR_USER.$XCOLLECTOR_GROUP /var/log/xcollector
if [ "$1" = "0" ]; then
# stop service before starting the uninstall
service xcollector stop
chkconfig --del xcollector
fi

%postun
Expand Down

0 comments on commit 9dc8cd0

Please sign in to comment.