chore: remove unused CircleCI scripts (#24701)

pull/24714/head
Brandon Pfeifer 2024-02-28 09:48:57 -05:00 committed by GitHub
parent 8fec1d636e
commit 3dcf2778d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 0 additions and 1433 deletions

View File

@ -1,48 +0,0 @@
#!/bin/bash
set -o nounset \
-o errexit \
-o pipefail
REGEX_TAG='v([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)'
function semver_tags()
{
{
# Sometimes several release tags point to the same commit (see v1.9.0 and
# v1.9.1). This iterates through each tag and ensures that it conforms to
# semantic versioning requirements. Afterwards, the tags are sorted from
# latest to earliest. This is so packages use the latest version tag.
for tag in $(git tag --points-at HEAD)
do
if [[ ${tag} =~ ^${REGEX_TAG}$ ]]
then
printf '%s\n' "${tag}"
fi
done
} | sort --version-sort --reverse
}
TAG=$(head -n 1 <<<"$(semver_tags)")
# If no tag could be found for the corresponding commit, assume that this
# is being built from an unversioned branch. In which case, this will
# construct a version that is compatible with Debian versioning:
# ${PREFIX}-<< short commit hash >>
if [[ ${TAG} =~ ^${REGEX_TAG}$ ]]
then
cat <<EOF >>"${BASH_ENV}"
export VERSION="${TAG:1}"
export MAJOR=${BASH_REMATCH[1]}
export MINOR=${BASH_REMATCH[2]}
export PATCH=${BASH_REMATCH[3]}
export RELEASE=1
EOF
else
cat <<EOF >>"${BASH_ENV}"
export VERSION="${PREFIX}-$(git rev-parse --short HEAD)"
export MAJOR=
export MINOR=
export PATCH=
export RELEASE=
EOF
fi

View File

@ -1,7 +0,0 @@
#!/bin/bash
set -euo pipefail
if [[ "${MACHTYPE}" == "arm64-apple-darwin"* ]]
then
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
fi

View File

@ -1,8 +0,0 @@
#!/bin/bash
set -o errexit \
-o nounset \
-o pipefail
path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
"${path}/validate" deb "${1}"

View File

@ -1,97 +0,0 @@
#!/bin/bash
set -o errexit \
-o nounset \
-o pipefail
# $1 -> architecture
# $2 -> package path
case ${1} in
x86_64) arch=x86_64 ;;
aarch64) arch=arm64 ;;
esac
package="$(realpath "${2}")"
path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
terraform_init() {
pushd "${path}/tf" &>/dev/null
# Unfortunately, CircleCI doesn't offer any RPM based machine images.
# This is required to test the functionality of the systemd services.
# (systemd doesn't run within docker containers). This will spawn a
# Amazon Linux instance in AWS.
terraform init
terraform apply \
-auto-approve \
-var "architecture=${1}" \
-var "package_path=${2}" \
-var "identifier=${CIRCLE_JOB}"
popd &>/dev/null
}
terraform_free() {
pushd "${path}/tf" &>/dev/null
terraform destroy \
-auto-approve \
-var "architecture=${1}" \
-var "package_path=${2}" \
-var "identifier=${CIRCLE_JOB}"
popd &>/dev/null
}
terraform_ip() {
pushd "${path}/tf" &>/dev/null
terraform output -raw node_ssh
popd &>/dev/null
}
# This ensures that the associated resources within AWS are released
# upon exit or when encountering an error. This is setup before the
# call to "terraform apply" so even partially initialized resources
# are released.
# shellcheck disable=SC2064
trap "terraform_free \"${arch}\" \"${package}\"" \
SIGINT \
SIGTERM \
ERR \
EXIT
function terraform_setup()
{
# TODO(bnpfeife): remove this once the executor is updated.
#
# Unfortunately, terraform provided by the CircleCI executor is *terribly*
# out of date. Most Linux distributions are disabling "ssh-rsa" public key
# algorithms which this uses to remote into the ec2 instance . This
# installs the latest version of terraform.
#
# Addendum: the "terraform_version" CircleCI option is broken!
sudo tee /etc/apt/sources.list.d/hashicorp.list <<EOF >/dev/null || true
deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main
EOF
curl -fL https://apt.releases.hashicorp.com/gpg | gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg >/dev/null
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get update
sudo -E apt-get install --yes terraform
}
terraform_setup
terraform_init "${arch}" "${package}"
printf 'Setup complete! Testing %s... (this takes several minutes!)' "${1}"
# Since terraform *just* created this instance, the host key is not
# known. Therefore, we'll disable StrictHostKeyChecking so ssh does
# not wait for user input.
ssh -o 'StrictHostKeyChecking=no' "ec2-user@$(terraform_ip)" 'sudo ./validate rpm ./influxdb2.rpm'

View File

@ -1,114 +0,0 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 2.70"
}
}
}
variable "architecture" {
type = string
}
variable "identifier" {
type = string
}
variable "package_path" {
type = string
}
provider "aws" {
region = "us-east-1"
}
data "aws_ami" "test_ami" {
most_recent = true
filter {
name = "name"
values = ["al20*-ami-20*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "architecture"
values = [var.architecture]
}
owners = ["137112412989"]
}
resource "aws_security_group" "influxdb_test_package_sg" {
ingress {
description = "Allow ssh connection"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
description = "Allow all outgoing"
from_port = 0
to_port = 0
protocol = "all"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "test_instance" {
count = 1
ami = data.aws_ami.test_ami.id
instance_type = var.architecture == "x86_64" ? "t2.micro" : "c6g.medium"
key_name = "circleci-oss-test"
vpc_security_group_ids = [aws_security_group.influxdb_test_package_sg.id]
tags = {
Name = format("circleci_%s_test_%s", var.identifier, var.architecture)
}
provisioner "file" {
source = var.package_path
destination = "/home/ec2-user/influxdb2.rpm"
connection {
type = "ssh"
user = "ec2-user"
host = self.public_dns
agent = true
}
}
provisioner "file" {
source = "../validate"
destination = "/home/ec2-user/validate"
connection {
type = "ssh"
user = "ec2-user"
host = self.public_dns
agent = true
}
}
provisioner "remote-exec" {
inline = [
"chmod +x /home/ec2-user/validate",
]
connection {
type = "ssh"
user = "ec2-user"
host = self.public_dns
agent = true
}
}
}
output "node_ssh" {
value = aws_instance.test_instance.0.public_dns
}

View File

@ -1,116 +0,0 @@
#!/bin/bash
set -o errexit \
-o nounset \
-o pipefail
usage() {
cat <<'EOF'
usage: validate [type] [path]
Program:
This application performs sanity checks on the provided InfluxDB
package. InfluxDB should *not* be installed on the system before
running this application. This validates new installations and
performs specific checks relevant only to InfluxDB.
Options:
type Must be "deb" or "rpm". This option instructs the
application to use the package manager associated
with "type".
path Path to InfluxDB package to validate.
EOF
}
if [[ ! "${1:-}" ]] || [[ ! "${2:-}" ]]
then
(usage) && exit 1
fi
PACKAGE_TYPE="${1}"
PACKAGE_PATH="${2}"
install_deb() {
# When installing the package, ensure that the latest repository listings
# are available. This might be required so that all dependencies resolve.
# Since this needs to be run by CI, we supply "noninteractive" and "-y"
# so no prompts stall the pipeline.
export DEBIAN_FRONTEND=noninteractive
apt-get update
# "apt-get install" should be used instead of "dpkg -i", because "dpkg"
# does not resolve dependencies. "apt-get" requires that the package
# path looks like a path (either fullpath or prefixed with "./").
apt-get install -y binutils "$(realpath "${PACKAGE_PATH}")"
}
install_rpm() {
# see "install_deb" for "update"
yum update -y
yum install -y binutils
yum localinstall -y "$(realpath "${PACKAGE_PATH}")"
}
case ${PACKAGE_TYPE}
in
deb)
(install_deb)
;;
rpm)
(install_rpm)
;;
esac
if ! which influxd &>/dev/null
then
printf 'ERROR: Failed to locate influxd executable!\n' >&2
exit 2
fi
NEEDED="$(readelf -d "$(which influxd)" | (grep 'NEEDED' || true ))"
# shellcheck disable=SC2181
if [[ ${?} -ne 0 ]]
then
cat <<'EOF'
ERROR: readelf could not analyze the influxd executable! This
might be the consequence of installing a package built
for another platform OR invalid compiler/linker flags.
EOF
exit 2
fi
if [[ "${NEEDED:-}" ]]
then
cat <<'EOF'
ERROR: influxd not statically linked! This may prevent all
platforms from running influxd without installing
separate dependencies.
EOF
exit 2
fi
PIE="$(readelf -d "$(which influxd)" | (grep 'Flags: PIE' || true))"
if [[ ! "${PIE:-}" ]]
then
printf 'ERROR: influxd not linked with "-fPIE"!\n'
exit 2
fi
if ! systemctl is-active influxdb &>/dev/null
then
systemctl start influxdb
fi
for i in 0..2
do
if ! systemctl is-active influxdb &>/dev/null
then
printf 'ERROR: influxdb service failed to start!\n'
exit 2
fi
# Sometimes the service fails several seconds or minutes after
# starting. This failure may not propagate to the original
# "systemctl start <influxdb>" command. Therefore, we'll
# poll the service several times before exiting.
sleep 30
done
printf 'Finished validating influxdb!\n'

View File

@ -1,383 +0,0 @@
#!/usr/bin/env python3
import os
import re
import shutil
import subprocess
import tempfile
import yaml
def build_linux_archive(source, package, version):
"""
Builds a Linux Archive.
This archive contains the binary artifacts, configuration, and scripts
installed by the DEB and RPM packages. This mimics the file-system. So,
binaries are installed into "/usr/bin", configuration into "/etc", and
scripts into their relevant directories. Permissions match those of
the DEB and RPM packages.
"""
with tempfile.TemporaryDirectory() as workspace:
# fmt: off
shutil.copytree(os.path.join(package["source"], "fs"),
workspace, dirs_exist_ok=True, ignore=shutil.ignore_patterns(".keepdir"))
# fmt: on
for extra in package["extras"]:
# fmt: off
shutil.copy(extra["source"],
os.path.join(workspace, extra["target"]))
# fmt: on
for binary in package["binaries"]:
target = os.path.join(source["binary"], binary)
if os.path.exists(target):
# fmt: off
shutil.copy(target,
os.path.join(workspace, "usr/bin", os.path.basename(target)))
# fmt: on
# After the package contents are copied into the working directory,
# the permissions must be updated. Since the CI executor may change
# occasionally (images/ORBs deprecated over time), the umask may
# not be what we expect. This allows this packaging script to be
# agnostic to umask/system configuration.
for root, dirs, files in os.walk(workspace):
for target in [os.path.join(root, f) for f in files]:
# files in "usr/bin" are executable
if os.path.relpath(root, workspace) == "usr/bin":
os.chmod(target, 0o0755)
else:
# standard file permissions
os.chmod(target, 0o0644)
# fmt: off
shutil.chown(
target,
user = "root",
group = "root")
# fmt: on
for target in [os.path.join(root, d) for d in dirs]:
# standard directory permissions
os.chmod(target, 0o0755)
# fmt: off
shutil.chown(
target,
user = "root",
group = "root")
# fmt: on
for override in package["perm_overrides"]:
target = os.path.join(workspace, override["target"])
os.chmod(target, override["perms"])
# "owner" and "group" should be a system account and group with
# a well-defined UID and GID. Otherwise, the UID/GID might vary
# between systems. When the archive is extracted/package is
# installed, things may not behave as we would expect.
# fmt: off
shutil.chown(
target,
user = override["owner"],
group = override["group"])
# fmt: on
os.makedirs(source["target"], exist_ok=True)
# fmt: off
subprocess.check_call([
"tar", "-czf",
os.path.join(
source["target"],
"{:s}-{:s}_{:s}_{:s}.tar.gz".format(
package["name"],
version,
source["plat"],
source["arch"]
)
),
# ".keepdir" allows Git to track otherwise empty directories. The presence
# of the directories allows `package["extras"]` and `package["binaries"]`
# to be copied into the archive without requiring "mkdir". These should
# directories are excluded from the final archive.
"--exclude", ".keepdir",
# This re-parents the contents of the archive with `package["name"]-version`.
# It is undocumented, however, when matching, "--transform" always removes
# the trailing slash. This regex must handle "./" and "./<more components>".
"--transform",
"s#^.\(/\|$\)#{:s}-{:s}/#".format(
package["name"],
version
),
# compress everything within `workspace`
"-C", workspace, '.'
])
# fmt: on
def build_archive(source, package, version):
"""
Builds Archive for other (not-Linux) Platforms.
This archive contains binary artifacts and configuration. Unlike the
linux archive, which contains the configuration and matches the file-
system of the DEB and RPM packages, everything is located within the
root of the archive. However, permissions do match those of the DEB
and RPM packages.
"""
with tempfile.TemporaryDirectory() as workspace:
for extra in package["extras"]:
# fmt: off
target = os.path.join(workspace,
os.path.basename(extra["target"]))
# fmt: on
shutil.copy(extra["source"], target)
os.chmod(target, 0o0644)
# fmt: off
shutil.chown(
target,
user = "root",
group = "root")
# fmt: on
for binary in package["binaries"]:
target = os.path.join(source["binary"], binary)
if os.path.exists(target):
# fmt: off
shutil.copy(target,
os.path.join(workspace, os.path.basename(target)))
# fmt: on
os.chmod(target, 0o0755)
# fmt: off
shutil.chown(
target,
user = "root",
group = "root")
# fmt: on
os.makedirs(source["target"], exist_ok=True)
if source["plat"] == "darwin":
# fmt: off
subprocess.check_call([
"tar", "-czf",
os.path.join(
source["target"],
"{:s}-{:s}_{:s}_{:s}.tar.gz".format(
package["name"],
version,
source["plat"],
source["arch"]
)
),
# This re-parents the contents of the archive with `package["name"]-version`.
# It is undocumented, however, when matching, "--transform" always removes
# the trailing slash. This regex must handle "./" and "./<more components>".
"--transform",
"s#^.\(/\|$\)#{:s}-{:s}/#".format(
package["name"],
version
),
# compress everything within `workspace`
"-C", workspace, '.'
])
# fmt: on
if source["plat"] == "windows":
# preserve current working directory
current = os.getcwd()
for root, dirs, files in os.walk(workspace):
for file in files:
# Unfortunately, it looks like "-r" cannot be combined with
# "-j" (which strips the path of input files). This changes
# directory to the current input file and *then* appends it
# to the archive.
os.chdir(os.path.join(workspace, root))
# fmt: off
subprocess.check_call([
"zip", "-r",
os.path.join(
os.path.join(current, source["target"]),
"{:s}-{:s}-{:s}.zip".format(
package["name"],
version,
source["plat"],
source["arch"]
)
),
file
])
# fmt: on
# restore current working directory
os.chdir(current)
def build_linux_package(source, package, version):
"""
Constructs a DEB or RPM Package.
"""
with tempfile.TemporaryDirectory() as workspace:
# fmt: off
shutil.copytree(package["source"], workspace,
dirs_exist_ok=True, ignore=shutil.ignore_patterns(".keepdir"))
# fmt: on
for extra in package["extras"]:
# fmt: off
shutil.copy(extra["source"],
os.path.join(workspace, "fs", extra["target"]))
# fmt: on
for binary in package["binaries"]:
target = os.path.join(source["binary"], binary)
if os.path.exists(target):
# fmt: off
shutil.copy(target,
os.path.join(workspace, "fs/usr/bin", os.path.basename(target)))
# fmt: on
# After the package contents are copied into the working directory,
# the permissions must be updated. Since the CI executor may change
# occasionally (images/ORBs deprecated over time), the umask may
# not be what we expect. This allows this packaging script to be
# agnostic to umask/system configuration.
for root, dirs, files in os.walk(workspace):
for target in [os.path.join(root, f) for f in files]:
# files in "fs/usr/bin" are executable
if os.path.relpath(root, workspace) == "fs/usr/bin":
os.chmod(target, 0o0755)
else:
# standard file permissions
os.chmod(target, 0o0644)
# fmt: off
shutil.chown(
target,
user = "root",
group = "root")
# fmt: on
for target in [os.path.join(root, d) for d in dirs]:
# standard directory permissions
os.chmod(target, 0o0755)
# fmt: off
shutil.chown(
target,
user = "root",
group = "root")
# fmt: on
for override in package["perm_overrides"]:
target = os.path.join(workspace, "fs", override["target"])
os.chmod(target, override["perms"])
# "owner" and "group" should be a system account and group with
# a well-defined UID and GID. Otherwise, the UID/GID might vary
# between systems. When the archive is extracted/package is
# installed, things may not behave as we would expect.
# fmt: off
shutil.chown(
target,
user = override["owner"],
group = override["group"])
# fmt: on
os.makedirs(source["target"], exist_ok=True)
fpm_wrapper(source, package, version, workspace, "rpm")
fpm_wrapper(source, package, version, workspace, "deb")
def fpm_wrapper(source, package, version, workspace, package_type):
"""
Constructs either a DEB/RPM Package.
This wraps some configuration settings that are *only* relevant
to `fpm`.
"""
conffiles = []
for root, dirs, files in os.walk(os.path.join(workspace, "fs/etc")):
for file in files:
# fmt: off
conffiles.extend([
"--config-files", os.path.join("/", os.path.relpath(root, os.path.join(workspace, "fs")), file)
])
# fmt: on
# `source["arch"]` matches DEB architecture names. When building RPMs, it must
# be converted into RPM architecture names.
architecture = source["arch"]
if package_type == "rpm":
if architecture == "amd64":
architecture = "x86_64"
if architecture == "arm64":
architecture = "aarch64"
# fmt: off
p = subprocess.check_call([
"fpm",
"--log", "error",
# package description
"--name", package["name"],
"--vendor", "InfluxData",
"--description", "Distributed time-series database.",
"--url", "https://influxdata.com",
"--maintainer", "support@influxdb.com",
"--license", "MIT",
# package configuration
"--input-type", "dir",
"--output-type", package_type,
"--architecture", architecture,
"--version", version,
"--iteration", "1",
# maintainer scripts
"--after-install", os.path.join(workspace, "control/postinst"),
"--after-remove", os.path.join(workspace, "control/postrm"),
"--before-install", os.path.join(workspace, "control/preinst"),
# package relationships
"--deb-recommends", "influxdb2-cli",
"--conflicts", "influxdb",
"--depends", "curl",
# package conffiles
*conffiles,
# package options
"--chdir", os.path.join(workspace, "fs/"),
"--package", source["target"]
])
# fmt: on
circle_tag = os.getenv("CIRCLE_TAG", default="")
circle_sha = os.getenv("CIRCLE_SHA1", default="DEADBEEF")
# Determine if `circle_tag` matches the semantic version regex. Otherwise,
# assume that `circle_tag` is not intended to tag a release. The regex is
# permissive of what occurs after the semantic version. This allows for
# alphas, betas, and release candidates.
if re.match("^v[0-9]+.[0-9]+.[0-9]+", circle_tag):
version = circle_tag[1:]
else:
# When `circle_tag` cannot be used to construct the package version,
# use `circle_sha`. Since `circle_sha` can start with an alpha (non-
# -numeric) character, prefix it with "2.x-".
version = "2.x-" + circle_sha[:8]
with open(".circleci/scripts/package/config.yaml") as file:
document = yaml.load(file, Loader=yaml.SafeLoader)
# fmt: off
for s, p in [
(s, p)
for s in document["sources" ]
for p in document["packages"]
]:
# fmt: on
if s["plat"] == "linux":
build_linux_archive(s, p, version)
build_linux_package(s, p, version)
if s["plat"] == "darwin" or s["plat"] == "windows":
build_archive(s, p, version)

View File

@ -1,49 +0,0 @@
---
sources:
- binary: /tmp/workspace/bin/influxd_linux_amd64/
target: artifacts/
arch: amd64
plat: linux
- binary: /tmp/workspace/bin/influxd_linux_arm64/
target: artifacts/
arch: arm64
plat: linux
- binary: /tmp/workspace/bin/influxd_darwin_amd64/
target: artifacts/
arch: amd64
plat: darwin
- binary: /tmp/workspace/bin/influxd_windows_amd64/
target: artifacts/
arch: amd64
plat: windows
packages:
- name: influxdb2
binaries:
- influxd
- influxd.exe
extras:
- source: LICENSE
target: usr/share/influxdb/LICENSE
- source: README.md
target: usr/share/influxdb/README.md
perm_overrides:
- owner: root
group: root
perms: 0755
target: usr/share/influxdb/influxdb2-upgrade.sh
- owner: root
group: root
perms: 0755
target: usr/lib/influxdb/scripts/init.sh
- owner: root
group: root
perms: 0755
target: usr/lib/influxdb/scripts/influxd-systemd-start.sh
source: .circleci/scripts/package/influxdb2

View File

@ -1,142 +0,0 @@
#!/bin/bash
BIN_DIR=/usr/bin
DATA_DIR=/var/lib/influxdb
LOG_DIR=/var/log/influxdb
SCRIPT_DIR=/usr/lib/influxdb/scripts
LOGROTATE_DIR=/etc/logrotate.d
INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml
function install_init {
cp -f $SCRIPT_DIR/init.sh /etc/init.d/influxdb
chmod +x /etc/init.d/influxdb
}
function install_systemd {
cp -f $SCRIPT_DIR/influxdb.service /lib/systemd/system/influxdb.service
systemctl enable influxdb
}
function install_update_rcd {
update-rc.d influxdb defaults
}
function install_chkconfig {
chkconfig --add influxdb
}
function should_upgrade {
if [[ ! -s /etc/influxdb/influxdb.conf ]]; then
# No V1 config present, no upgrade needed.
return 1
fi
bolt_dir="/root/.influxdbv2 /var/lib/influxdb/.influxdbv2 /var/lib/influxdb"
for bolt in $bolt_dir; do
if [[ -s ${bolt}/influxd.bolt ]]; then
# Found a bolt file, assume previous v2 upgrade.
return 1
fi
done
return 0
}
function upgrade_notice {
cat << EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Important 1.x to 2.x Upgrade Notice !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thank you for installing InfluxDB v2. Due to significant changes between
the v1 and v2 versions, upgrading to v2 requires additional steps. If
upgrading to v2 was not intended, simply re-install the v1 package now.
An upgrade helper script is available that should be reviewed and executed
prior to starting the influxdb systemd service. In order to start the v2
upgrade, execute the following:
sudo /usr/share/influxdb/influxdb2-upgrade.sh
Visit our website for complete details on the v1 to v2 upgrade process:
https://docs.influxdata.com/influxdb/latest/upgrade/v1-to-v2/
For new or upgrade installations, please review the getting started guide:
https://docs.influxdata.com/influxdb/latest/get-started/
EOF
}
function init_config {
mkdir -p $(dirname ${INFLUXD_CONFIG_PATH})
local config_path=${INFLUXD_CONFIG_PATH}
if [[ -s ${config_path} ]]; then
config_path=${INFLUXD_CONFIG_PATH}.defaults
echo "Config file ${INFLUXD_CONFIG_PATH} already exists, writing defaults to ${config_path}"
fi
cat << EOF > ${config_path}
bolt-path = "/var/lib/influxdb/influxd.bolt"
engine-path = "/var/lib/influxdb/engine"
EOF
}
# Add defaults file, if it doesn't exist
if [[ ! -s /etc/default/influxdb2 ]]; then
cat << EOF > /etc/default/influxdb2
INFLUXD_CONFIG_PATH=${INFLUXD_CONFIG_PATH}
EOF
fi
# Remove legacy symlink, if it exists
if [[ -L /etc/init.d/influxdb ]]; then
rm -f /etc/init.d/influxdb
fi
# Distribution-specific logic
if [[ -f /etc/redhat-release ]]; then
# RHEL-variant logic
if command -v systemctl &>/dev/null; then
install_systemd
else
# Assuming sysv
install_init
install_chkconfig
fi
elif [[ -f /etc/debian_version ]]; then
# Ownership for RH-based platforms is set in build.py via the `rmp-attr` option.
# We perform ownership change only for Debian-based systems.
# Moving these lines out of this if statement would make `rmp -V` fail after installation.
chown -R -L influxdb:influxdb $LOG_DIR
chown -R -L influxdb:influxdb $DATA_DIR
chmod 755 $LOG_DIR
chmod 755 $DATA_DIR
# Debian/Ubuntu logic
if command -v systemctl &>/dev/null; then
install_systemd
else
# Assuming sysv
install_init
install_update_rcd
fi
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ "$NAME" = "Amazon Linux" ]]; then
# Amazon Linux 2+ logic
install_systemd
elif [[ "$NAME" = "Amazon Linux AMI" ]]; then
# Amazon Linux logic
install_init
install_chkconfig
fi
fi
# Check upgrade status
if should_upgrade; then
upgrade_notice
else
init_config
fi

View File

@ -1,58 +0,0 @@
#!/bin/bash
function disable_systemd {
systemctl disable influxdb
rm -f /lib/systemd/system/influxdb.service
}
function disable_update_rcd {
update-rc.d -f influxdb remove
rm -f /etc/init.d/influxdb
}
function disable_chkconfig {
chkconfig --del influxdb
rm -f /etc/init.d/influxdb
}
if [[ -f /etc/redhat-release ]]; then
# RHEL-variant logic
if [[ "$1" = "0" ]]; then
# InfluxDB is no longer installed, remove from init system
rm -f /etc/default/influxdb
if command -v systemctl &>/dev/null; then
disable_systemd
else
# Assuming sysv
disable_chkconfig
fi
fi
elif [[ -f /etc/lsb-release ]]; then
# Debian/Ubuntu logic
if [[ "$1" != "upgrade" ]]; then
# Remove/purge
rm -f /etc/default/influxdb
if command -v systemctl &>/dev/null; then
disable_systemd
else
# Assuming sysv
disable_update_rcd
fi
fi
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ "$ID" = "amzn" ]] && [[ "$1" = "0" ]]; then
# InfluxDB is no longer installed, remove from init system
rm -f /etc/default/influxdb
if [[ "$NAME" = "Amazon Linux" ]]; then
# Amazon Linux 2+ logic
disable_systemd
elif [[ "$NAME" = "Amazon Linux AMI" ]]; then
# Amazon Linux logic
disable_chkconfig
fi
fi
fi

View File

@ -1,22 +0,0 @@
#!/bin/bash
DATA_DIR=/var/lib/influxdb
USER=influxdb
GROUP=influxdb
LOG_DIR=/var/log/influxdb
if ! id influxdb &>/dev/null; then
useradd --system -U -M influxdb -s /bin/false -d $DATA_DIR
fi
# check if DATA_DIR exists
if [ ! -d "$DATA_DIR" ]; then
mkdir -p $DATA_DIR
chown $USER:$GROUP $DATA_DIR
fi
# check if LOG_DIR exists
if [ ! -d "$LOG_DIR" ]; then
mkdir -p $LOG_DIR
chown $USER:$GROUP $DATA_DIR
fi

View File

@ -1,8 +0,0 @@
/var/log/influxdb/influxd.log {
daily
rotate 7
missingok
dateext
copytruncate
compress
}

View File

@ -1 +0,0 @@
This prevents Git from removing this directory.

View File

@ -1,30 +0,0 @@
#!/bin/bash -e
/usr/bin/influxd &
PID=$!
echo $PID > /var/lib/influxdb/influxd.pid
PROTOCOL="http"
BIND_ADDRESS=$(influxd print-config --key-name http-bind-address)
TLS_CERT=$(influxd print-config --key-name tls-cert | tr -d '"')
TLS_KEY=$(influxd print-config --key-name tls-key | tr -d '"')
if [ -n "${TLS_CERT}" ] && [ -n "${TLS_KEY}" ]; then
echo "TLS cert and key found -- using https"
PROTOCOL="https"
fi
HOST=${BIND_ADDRESS%:*}
HOST=${HOST:-"localhost"}
PORT=${BIND_ADDRESS##*:}
set +e
attempts=0
url="$PROTOCOL://$HOST:$PORT/ready"
result=$(curl -k -s -o /dev/null $url -w %{http_code})
while [ "${result:0:2}" != "20" ] && [ "${result:0:2}" != "40" ]; do
attempts=$(($attempts+1))
echo "InfluxDB API at $url unavailable after $attempts attempts..."
sleep 1
result=$(curl -k -s -o /dev/null $url -w %{http_code})
done
echo "InfluxDB started"
set -e

View File

@ -1,27 +0,0 @@
# If you modify this, please also make sure to edit init.sh
[Unit]
Description=InfluxDB is an open-source, distributed, time series database
Documentation=https://docs.influxdata.com/influxdb/
After=network-online.target
[Service]
User=influxdb
Group=influxdb
LimitNOFILE=65536
EnvironmentFile=-/etc/default/influxdb2
ExecStart=/usr/lib/influxdb/scripts/influxd-systemd-start.sh
KillMode=control-group
Restart=on-failure
Type=forking
PIDFile=/var/lib/influxdb/influxd.pid
StateDirectory=influxdb
StateDirectoryMode=0750
LogsDirectory=influxdb
LogsDirectoryMode=0750
UMask=0027
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target
Alias=influxd.service

View File

@ -1,238 +0,0 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: influxd
# Required-Start: $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the InfluxDB process
### END INIT INFO
# If you modify this, please make sure to also edit influxdb.service
# Environment variables can be set in /etc/default/influxdb2. These will override
# any corresponding config file values.
DEFAULT=/etc/default/influxdb2
# Daemon options
INFLUXD_OPTS=
# Process name ( For display )
NAME=influxdb
# User and group
USER=influxdb
GROUP=influxdb
if [ -n "${INFLUXD_SERVICE_UMASK:-}" ]
then
umask "${INFLUXD_SERVICE_UMASK}"
else
umask 0027
fi
# Check for sudo or root privileges before continuing
if [ "$UID" != "0" ]; then
echo "You must be root to run this script"
exit 1
fi
# Daemon name, where is the actual executable If the daemon is not
# there, then exit.
DAEMON=/usr/bin/influxd
if [ ! -x $DAEMON ]; then
echo "Executable $DAEMON does not exist!"
exit 5
fi
# PID file for the daemon
PIDFILE=/var/run/influxdb/influxd.pid
piddir="$(dirname "${PIDFILE}")"
if [ ! -d "${piddir}" ]; then
mkdir -p "${piddir}"
chown "${USER}:${GROUP}" "${piddir}"
chmod 0750 "${piddir}"
fi
# Max open files
OPEN_FILE_LIMIT=65536
if [ -r /lib/lsb/init-functions ]; then
source /lib/lsb/init-functions
fi
# Logging
if [ -z "$STDOUT" ]; then
STDOUT=/var/log/influxdb/influxd.log
fi
outdir="$(dirname "${STDOUT}")"
if [ ! -d "${outdir}" ]; then
mkdir -p "${outdir}"
chmod 0750 "${outdir}"
fi
if [ -z "$STDERR" ]; then
STDERR=/var/log/influxdb/influxd.log
fi
errdir="$(dirname "${STDERR}")"
if [ ! -d "${errdir}" ]; then
mkdir -p "${errdir}"
chmod 0750 "${errdir}"
fi
# Override init script variables with DEFAULT values
if [ -r $DEFAULT ]; then
# set -a causes all variables to be auto-exported.
set -a
source $DEFAULT
set +a
fi
function log_failure_msg() {
echo "$@" "[ FAILED ]"
}
function log_success_msg() {
echo "$@" "[ OK ]"
}
function start() {
# Check that the PID file exists, and check the actual status of process
if [ -f $PIDFILE ]; then
PID="$(cat $PIDFILE)"
if kill -0 "$PID" &>/dev/null; then
# Process is already up
log_success_msg "$NAME process is already running"
return 0
fi
else
su -s /bin/sh -c "touch $PIDFILE" $USER &>/dev/null
if [ $? -ne 0 ]; then
log_failure_msg "$PIDFILE not writable, check permissions"
exit 5
fi
fi
# Bump the file limits, before launching the daemon. These will
# carry over to launched processes.
ulimit -n $OPEN_FILE_LIMIT
if [ $? -ne 0 ]; then
log_failure_msg "Unable to set ulimit to $OPEN_FILE_LIMIT"
exit 1
fi
# Launch process
echo "Starting $NAME..."
if command -v start-stop-daemon &>/dev/null; then
start-stop-daemon \
--chuid $USER:$GROUP \
--start \
--quiet \
--pidfile $PIDFILE \
--exec $DAEMON \
-- \
$INFLUXD_OPTS >>$STDOUT 2>>$STDERR &
else
local CMD="$DAEMON $INFLUXD_OPTS >>$STDOUT 2>>$STDERR &"
su -s /bin/sh -c "$CMD" $USER
fi
# Sleep to verify process is still up
sleep 1
echo $(pgrep -u $USER -f influxd) > $PIDFILE
if [ -f $PIDFILE ]; then
# PIDFILE exists
if kill -0 $(cat $PIDFILE) &>/dev/null; then
# PID up, service running
log_success_msg "$NAME process was started"
return 0
fi
fi
log_failure_msg "$NAME process was unable to start"
exit 1
}
function stop() {
# Stop the daemon.
if [ -f $PIDFILE ]; then
local PID="$(cat $PIDFILE)"
if kill -0 $PID &>/dev/null; then
echo "Stopping $NAME..."
# Process still up, send SIGTERM and remove PIDFILE
kill -s TERM $PID &>/dev/null && rm -f "$PIDFILE" &>/dev/null
n=0
while true; do
# Enter loop to ensure process is stopped
kill -0 $PID &>/dev/null
if [ "$?" != "0" ]; then
# Process stopped, break from loop
log_success_msg "$NAME process was stopped"
return 0
fi
# Process still up after signal, sleep and wait
sleep 1
n=$(expr $n + 1)
if [ $n -eq 30 ]; then
# After 30 seconds, send SIGKILL
echo "Timeout exceeded, sending SIGKILL..."
kill -s KILL $PID &>/dev/null
elif [ $? -eq 40 ]; then
# After 40 seconds, error out
log_failure_msg "could not stop $NAME process"
exit 1
fi
done
fi
fi
log_success_msg "$NAME process already stopped"
}
function restart() {
# Restart the daemon.
stop
start
}
function status() {
# Check the status of the process.
if [ -f $PIDFILE ]; then
PID="$(cat $PIDFILE)"
if kill -0 $PID &>/dev/null; then
log_success_msg "$NAME process is running"
exit 0
fi
fi
log_failure_msg "$NAME process is not running"
exit 1
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
version)
$DAEMON version
;;
*)
# For invalid arguments, print the usage message.
echo "Usage: $0 {start|stop|restart|status|version}"
exit 2
;;
esac

View File

@ -1,83 +0,0 @@
#!/bin/bash
# Environment defaults
INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml
INFLUXD_BOLT_PATH=/var/lib/influxdb/influxd.bolt
INFLUXD_ENGINE_PATH=/var/lib/influxdb/engine
export INFLUXD_CONFIG_PATH INFLUXD_BOLT_PATH INFLUXD_ENGINE_PATH
# Check upgrade status
bolt_dir="/root/.influxdbv2 /var/lib/influxdb/.influxdbv2 /var/lib/influxdb"
for bolt in $bolt_dir
do
if [[ -s ${bolt}/influxd.bolt ]]; then
echo "An existing ${bolt}/influxd.bolt file was found indicating InfluxDB is"
echo "already upgraded to v2. Exiting."
exit 1
fi
done
# Perform upgrade
sudo /usr/bin/influxd upgrade \
--config-file=/etc/influxdb/influxdb.conf \
--log-path=/var/log/influxdb/upgrade.log \
--continuous-query-export-path=/var/lib/influxdb/continuous_queries.txt \
--v2-config-path=${INFLUXD_CONFIG_PATH} \
-m $INFLUXD_BOLT_PATH -e $INFLUXD_ENGINE_PATH
if [[ $? -eq 0 ]]; then
cat << EOF
The upgrade completed successfully. Execute the following to start InfluxDB:
sudo systemctl start influxdb
A complete copy of v1 data was created as part of the upgrade process.
After confirming v2 is functioning as intended, removal of v1 data can be
performed by executing:
sudo /var/tmp/influxdbv1-remove.sh
NOTE: This script will erase all previous v1 data and config files!
EOF
cat << EOF > /var/tmp/influxdbv1-remove.sh
#!/bin/bash
sudo rm -f /etc/influxdb/influxdb.conf
sudo rm -rf /var/lib/influxdb/data
sudo rm -rf /var/lib/influxdb/wal
sudo rm -rf /var/lib/influxdb/meta
EOF
sudo chmod +x /var/tmp/influxdbv1-remove.sh
sudo cp /root/.influxdbv2/configs /var/lib/influxdb
sudo chown influxdb:influxdb /var/lib/influxdb/influxd.bolt /var/lib/influxdb/configs
sudo chown -R influxdb:influxdb /var/lib/influxdb/engine
else
cat << EOF
The upgrade encountered an error. Please review the
/var/log/influxdb/upgrade.log file for more information. Before attempting
another upgrade, removal of v2 data should be performed by executing:
sudo /var/tmp/influxdbv2-remove.sh
NOTE: This script will erase all previous v2 data and config files!
EOF
cat << EOF > /var/tmp/influxdbv2-remove.sh
#!/bin/bash
sudo rm -f /etc/influxdb/config.toml /var/lib/influxdb/influxd.bolt
sudo rm -f /var/lib/influxdb/configs /root/.influxdbv2/configs
sudo rm -f /var/lib/influxdb/continuous_queries.txt
sudo rm -rf /var/lib/influxdb/engine
EOF
sudo chmod +x /var/tmp/influxdbv2-remove.sh
fi

View File

@ -1,2 +0,0 @@
PyYAML==6.0
regex==2023.6.3