Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build_and_push.sh #5

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:stretch
FROM debian:bookworm

ADD git-tag /git-tag

Expand Down
6 changes: 3 additions & 3 deletions build_and_push.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

MY_IMAGE_NAME="caprover/netdata"
NETDATA_VERSION="v1.34.1"
NETDATA_VERSION="v1.42.2"

# ensure you're not running it on local machine
if [ -z "$CI" ] || [ -z "$GITHUB_REF" ]; then
Expand All @@ -22,5 +22,5 @@ docker buildx ls
docker buildx create --name mybuilder
docker buildx use mybuilder

# REMOVED linux/arm64 as debie:jessie isn't built for linux/arm64
docker buildx build --platform linux/amd64,linux/arm,linux/arm64,linux/386 -t $MY_IMAGE_NAME:latest -t $MY_IMAGE_NAME:$NETDATA_VERSION --push .
# REMOVED linux/arm, and all 32 bit. Just focus on x86_64
docker buildx build --platform linux/amd64,linux/arm,linux/arm64,linux/386 -t $MY_IMAGE_NAME:latest -t $MY_IMAGE_NAME:$NETDATA_VERSION --push .
26 changes: 11 additions & 15 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
set -e
DEBIAN_FRONTEND=noninteractive

# some mirrors have issues, i skipped httpredir in favor of an eu mirror
# some mirrors have issues, i skipped httpredir in favor of an eu mirror, moved to bookworm, and they cause duplicates only.

echo "deb http://ftp.nl.debian.org/debian/ stretch main" > /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list
# echo "deb http://deb.debian.org/debian/ bookworm main" > /etc/apt/sources.list
# echo "deb http://security.debian.org/debian-security bookworm-security main" >> /etc/apt/sources.list

# install dependencies for build
# source: https://learn.netdata.cloud/docs/agent/packaging/installer/methods/manual

apt-get -qq update
apt-get -y install zlib1g-dev uuid-dev libmnl-dev gcc make curl git autoconf autogen automake pkg-config netcat-openbsd jq libuv1-dev liblz4-dev libjudy-dev libssl-dev cmake libelf-dev libprotobuf-dev protobuf-compiler g++
apt-get -y install autoconf-archive lm-sensors nodejs python python-mysqldb python-yaml libjudydebian1 libuv1 liblz4-1 openssl
apt-get -y install msmtp msmtp-mta apcupsd fping
apt-get update -qq && \
apt-get install -y ca-certificates git-man netcat-openbsd krb5-locales less libbrotli1 libbsd0 libcbor0.8 libcurl3-gnutls libcurl4 libedit2 liberror-perl libexpat1 libfido2-1 libgdbm-compat4 libgdbm6 libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 libldap-2.5-0 libldap-common libnghttp2-14 libperl5.36 libpsl5 librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libssh2-1 libssl3 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 netbase openssh-client openssl patch nodejs perl perl-modules-5.36 publicsuffix xauth && \
apt-get install -y autoconf autoconf-archive autogen automake cmake curl g++ gcc git gzip libatomic1 libuuid1 libelf-dev libjson-c-dev libjudy-dev liblz4-dev libmnl-dev libssl-dev libsystemd-dev libuv1-dev libyaml-dev lm-sensors make pkg-config python3 python3-mysqldb python3-yaml tar uuid-dev zlib1g-dev libprotobuf-dev protobuf-compiler && \
apt-get install -y msmtp msmtp-mta apcupsd fping

# fetch netdata
# fetch netdata & replaced firehol obsoleted by netdata

git clone https://github.com/firehol/netdata.git /netdata.git
git clone https://github.com/netdata/netdata.git /netdata.git
cd /netdata.git
TAG=$(</git-tag)
if [ ! -z "$TAG" ]; then
Expand All @@ -35,21 +35,17 @@ git submodule update --init --recursive

./netdata-installer.sh --dont-wait --dont-start-it --disable-telemetry

# removed hack on 2017/1/3
#chown root:root /usr/libexec/netdata/plugins.d/apps.plugin
#chmod 4755 /usr/libexec/netdata/plugins.d/apps.plugin

# remove build dependencies

cd /
rm -rf /netdata.git

dpkg -P zlib1g-dev uuid-dev libmnl-dev make git autoconf autogen automake pkg-config libuv1-dev liblz4-dev libjudy-dev libssl-dev cmake libelf-dev libprotobuf-dev protobuf-compiler g++
dpkg -P iproute2 libelf-dev libjudy-dev liblz4-dev libmnl-dev libprotobuf-dev libssl-dev libuv1-dev libyaml-dev lm-sensors make netcat-openbsd pkg-config protobuf-compiler python3-mysqldb python3-yaml uuid-dev zlib1g-dev

apt-get -y autoremove
apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


# symlink access log and error log to stdout/stderr

ln -sf /dev/stdout /var/log/netdata/access.log
Expand Down
46 changes: 41 additions & 5 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ fi
# copy conf from NETDATA_STOCK_CONFIG_DIR (normally under /usr/lib/netdata/conf.d) to NETDATA_USER_CONFIG_DIR (normally under /etc/netdata)
cp /usr/lib/netdata/conf.d/health_alarm_notify.conf /etc/netdata

# For EMAIL_SENDER, assuming the value comes from netDataInfo.data.smtp.sender
if [[ $SMTP_SENDER ]]; then
sed -i -e "s@EMAIL_SENDER=\"\"@EMAIL_SENDER=\"${SMTP_SENDER}\"@" /etc/netdata/health_alarm_notify.conf
fi

# For DEFAULT_RECIPIENT_EMAIL, assuming the value comes from netDataInfo.data.smtp.to
if [[ $SMTP_TO ]]; then
sed -i -e "s@DEFAULT_RECIPIENT_EMAIL=\"\"@DEFAULT_RECIPIENT_EMAIL=\"${SMTP_TO}\"@" /etc/netdata/health_alarm_notify.conf
fi

# For enabling email, set SEND_EMAIL to YES if both SMTP_SENDER and SMTP_TO are set
if [[ $SMTP_SENDER && $SMTP_TO ]]; then
sed -i -e "s@SEND_EMAIL=\"NO\"@SEND_EMAIL=\"YES\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $SLACK_WEBHOOK_URL ]]; then
sed -i -e "s@SLACK_WEBHOOK_URL=\"\"@SLACK_WEBHOOK_URL=\"${SLACK_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
fi
Expand All @@ -47,14 +62,24 @@ if [[ $SLACK_CHANNEL ]]; then
sed -i -e "s@DEFAULT_RECIPIENT_SLACK=\"\"@DEFAULT_RECIPIENT_SLACK=\"${SLACK_CHANNEL}\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $DISCORD_WEBHOOK_URL ]]; then
sed -i -e "s@DISCORD_WEBHOOK_URL=\"\"@DISCORD_WEBHOOK_URL=\"${DISCORD_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
# Add this part for the SEND_SLACK="YES"
if [[ $SLACK_WEBHOOK_URL && $SLACK_CHANNEL ]]; then
sed -i -e "s@SEND_SLACK=\"NO\"@SEND_SLACK=\"YES\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $DISCORD_RECIPIENT ]]; then
sed -i -e "s@DEFAULT_RECIPIENT_DISCORD=\"\"@DEFAULT_RECIPIENT_DISCORD=\"${DISCORD_RECIPIENT}\"@" /etc/netdata/health_alarm_notify.conf
fi
# if [[ $DISCORD_WEBHOOK_URL ]]; then
# sed -i -e "s@DISCORD_WEBHOOK_URL=\"\"@DISCORD_WEBHOOK_URL=\"${DISCORD_WEBHOOK_URL}\"@" /etc/netdata/health_alarm_notify.conf
# fi

# if [[ $DISCORD_RECIPIENT ]]; then
# sed -i -e "s@DEFAULT_RECIPIENT_DISCORD=\"\"@DEFAULT_RECIPIENT_DISCORD=\"${DISCORD_RECIPIENT}\"@" /etc/netdata/health_alarm_notify.conf
# fi
# # Add this part for the SEND_DISCORD="YES"
# if [[ $DISCORD_WEBHOOK_URL && $DISCORD_RECIPIENT ]]; then
# sed -i -e "s@SEND_DISCORD=\"NO\"@SEND_DISCORD=\"YES\"@" /etc/netdata/health_alarm_notify.conf
# fi

# For Telegram
if [[ $TELEGRAM_BOT_TOKEN ]]; then
sed -i -e "s@TELEGRAM_BOT_TOKEN=\"\"@TELEGRAM_BOT_TOKEN=\"${TELEGRAM_BOT_TOKEN}\"@" /etc/netdata/health_alarm_notify.conf
fi
Expand All @@ -63,6 +88,12 @@ if [[ $TELEGRAM_CHAT_ID ]]; then
sed -i -e "s@DEFAULT_RECIPIENT_TELEGRAM=\"\"@DEFAULT_RECIPIENT_TELEGRAM=\"${TELEGRAM_CHAT_ID}\"@" /etc/netdata/health_alarm_notify.conf
fi

# Add this part for the SEND_TELEGRAM="YES"
if [[ $TELEGRAM_BOT_TOKEN && $TELEGRAM_CHAT_ID ]]; then
sed -i -e "s@SEND_TELEGRAM=\"NO\"@SEND_TELEGRAM=\"YES\"@" /etc/netdata/health_alarm_notify.conf
fi

# For PushBullet
if [[ $PUSHBULLET_ACCESS_TOKEN ]]; then
sed -i -e "s@PUSHBULLET_ACCESS_TOKEN=\"\"@PUSHBULLET_ACCESS_TOKEN=\"${PUSHBULLET_ACCESS_TOKEN}\"@" /etc/netdata/health_alarm_notify.conf
fi
Expand All @@ -71,6 +102,11 @@ if [[ $PUSHBULLET_DEFAULT_EMAIL ]]; then
sed -i -e "s#DEFAULT_RECIPIENT_PUSHBULLET=\"\"#DEFAULT_RECIPIENT_PUSHBULLET=\"${PUSHBULLET_DEFAULT_EMAIL}\"#" /etc/netdata/health_alarm_notify.conf
fi

# Add this part for the SEND_PUSHBULLET="YES"
if [[ $PUSHBULLET_ACCESS_TOKEN && $PUSHBULLET_DEFAULT_EMAIL ]]; then
sed -i -e "s@SEND_PUSHBULLET=\"NO\"@SEND_PUSHBULLET=\"YES\"@" /etc/netdata/health_alarm_notify.conf
fi

if [[ $NETDATA_IP ]]; then
NETDATA_ARGS="${NETDATA_ARGS} -i ${NETDATA_IP}"
fi
Expand Down