You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
chore(install): no more deps for awk and ps for postinstall script
This commit is contained in:
@@ -5,11 +5,76 @@
|
||||
# Post-install steps for columnstore install
|
||||
|
||||
running_systemd() {
|
||||
if [ "$(ps --no-headers -o comm 1)" = "systemd" ]; then
|
||||
# Check if init process (PID 1) is systemd by reading /proc/1/comm
|
||||
if [ -r "/proc/1/comm" ]; then
|
||||
if [ "$(cat /proc/1/comm)" = "systemd" ]; then
|
||||
echo 0
|
||||
else
|
||||
echo 1
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Alternative check using /proc/1/exe symlink
|
||||
if [ -L "/proc/1/exe" ]; then
|
||||
local exe_target
|
||||
exe_target=$(readlink -f "/proc/1/exe")
|
||||
if [[ "${exe_target##*/}" == "systemd" ]]; then
|
||||
echo 0
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fallback check for systemd presence in /run/systemd
|
||||
if [ -d "/run/systemd/system" ]; then
|
||||
echo 0
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo 1
|
||||
return 1
|
||||
}
|
||||
|
||||
get_parent_pid() {
|
||||
local pid=$1
|
||||
local ppid
|
||||
|
||||
# Read the stat file for the given PID
|
||||
if [ -f "/proc/$pid/stat" ]; then
|
||||
# Read the entire stat file into a variable
|
||||
read -r stat <"/proc/$pid/stat"
|
||||
|
||||
# Split into array (parent PID is the 4th field)
|
||||
IFS=' ' read -ra stat_array <<<"$stat"
|
||||
|
||||
# The PPID is the 4th element (0-based index 3)
|
||||
ppid=${stat_array[3]}
|
||||
|
||||
echo "$ppid"
|
||||
return 0
|
||||
else
|
||||
echo "Error: Process $pid does not exist" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_env_var_value() {
|
||||
local pid=$1
|
||||
local var_name=$2
|
||||
local env_file="/proc/$pid/environ"
|
||||
|
||||
if [ ! -r "$env_file" ]; then
|
||||
echo "Error: Cannot read $env_file" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Read null-delimited environ file and process each line
|
||||
while IFS= read -r -d '' line; do
|
||||
if [[ "$line" == "${var_name}="* ]]; then
|
||||
echo "${line#*=}"
|
||||
return 0
|
||||
fi
|
||||
done <"$env_file"
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# This function recursively(up to PID 1) searches for
|
||||
@@ -19,13 +84,12 @@ find_env_var() {
|
||||
pid=$$
|
||||
ENV_VAR=''
|
||||
while [ -z "$ENV_VAR" -a "$pid" != 1 ]; do
|
||||
ppid=$(ps -oppid -p$pid|tail -1|awk '{print $1}')
|
||||
ppid=$(get_parent_pid $pid)
|
||||
# This condition is true in containers
|
||||
if [ "$ppid" == 0 ]; then
|
||||
break;
|
||||
break
|
||||
fi
|
||||
env=$(strings /proc/$ppid/environ)
|
||||
ENV_VAR=$(echo "$env"|awk -F= "\$1 == \"$env_var_name\" { print \$2; }")
|
||||
ENV_VAR=$(get_env_var_value $ppid $env_var_name)
|
||||
pid=$ppid
|
||||
done
|
||||
echo $ENV_VAR
|
||||
@@ -40,12 +104,12 @@ fi
|
||||
checkForError() {
|
||||
# check for password error
|
||||
grep "ERROR 1045" ${installLogDir}/mysql_install.log >${installLogDir}/error.check
|
||||
if [ `cat ${installLogDir}/error.check | wc -c` -ne 0 ]; then
|
||||
if [ $(cat ${installLogDir}/error.check | wc -c) -ne 0 ]; then
|
||||
echo "There were authentication issues running install_mcs_mysql.sh \
|
||||
script. The log is available in ${installLogDir}/mysql_install.log. Please re-run \
|
||||
columnstore-post-install manually after solving the authentication issues."
|
||||
rm -f ${installLogDir}/error.check
|
||||
return 2;
|
||||
return 2
|
||||
fi
|
||||
|
||||
rm -f ${installLogDir}/error.check
|
||||
@@ -66,11 +130,11 @@ columnstore-post-install manually after solving the authentication issues."
|
||||
|
||||
echo "columnstore exists"
|
||||
|
||||
return 0;
|
||||
return 0
|
||||
}
|
||||
|
||||
rpmmode=install
|
||||
user=`whoami 2>/dev/null`
|
||||
user=$(whoami 2>/dev/null)
|
||||
|
||||
quiet=0
|
||||
|
||||
@@ -112,7 +176,6 @@ if [ $? -ne 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
profileFile="/etc/profile.d/columnstoreAlias.sh"
|
||||
/bin/cp -f @ENGINE_SUPPORTDIR@/columnstoreAlias /etc/profile.d/columnstoreAlias.sh
|
||||
chmod 644 /etc/profile.d/columnstoreAlias.sh >/dev/null 2>&1
|
||||
@@ -147,8 +210,8 @@ rm -f @ENGINE_LOGDIR@/data/bulk/tmpjob/* >/dev/null 2>&1
|
||||
chmod -R 777 @ENGINE_LOGDIR@/data
|
||||
|
||||
#get columnstore temp file directory name
|
||||
tmpDir=`@ENGINE_BINDIR@/mcsGetConfig SystemConfig SystemTempFileDir`
|
||||
scratchDir=$tmpDir`@ENGINE_BINDIR@/mcsGetConfig SystemConfig hdfsRdwrScratch`
|
||||
tmpDir=$(@ENGINE_BINDIR@/mcsGetConfig SystemConfig SystemTempFileDir)
|
||||
scratchDir=$tmpDir$(@ENGINE_BINDIR@/mcsGetConfig SystemConfig hdfsRdwrScratch)
|
||||
mkdir $tmpDir >/dev/null 2>&1
|
||||
mkdir $scratchDir >/dev/null 2>&1
|
||||
chmod 777 $tmpDir
|
||||
@@ -162,7 +225,7 @@ if [ $user = "root" ]; then
|
||||
rm -f /etc/init.d/columnstore >/dev/null 2>&1
|
||||
rm -f /etc/default/columnstore
|
||||
|
||||
systemctl=`which systemctl 2>/dev/null`
|
||||
systemctl=$(which systemctl 2>/dev/null)
|
||||
if [ -n "$systemctl" ]; then
|
||||
# Removing a separate ExeMgr unit.
|
||||
if [[ -f /usr/lib/systemd/system/mcs-exemgr.service ]]; then
|
||||
@@ -199,7 +262,7 @@ if [ $user = "root" ]; then
|
||||
systemctl enable mcs-loadbrm >/dev/null 2>&1
|
||||
systemctl enable mcs-storagemanager >/dev/null 2>&1
|
||||
else
|
||||
chkconfig=`which chkconfig 2>/dev/null`
|
||||
chkconfig=$(which chkconfig 2>/dev/null)
|
||||
if [ -n "$chkconfig" ]; then
|
||||
|
||||
cp @ENGINE_SBINDIR@/columnstore /etc/init.d/. >/dev/null 2>&1
|
||||
@@ -207,7 +270,7 @@ if [ $user = "root" ]; then
|
||||
chkconfig columnstore on >/dev/null 2>&1
|
||||
else
|
||||
cp @ENGINE_SBINDIR@/columnstore /etc/init.d/. >/dev/null 2>&1
|
||||
updaterc=`which update-rc.d 2>/dev/null`
|
||||
updaterc=$(which update-rc.d 2>/dev/null)
|
||||
if [ -n "$updaterc" ]; then
|
||||
|
||||
update-rc.d columnstore defaults 99 >/dev/null 2>&1
|
||||
@@ -375,7 +438,7 @@ fi
|
||||
if [ $(running_systemd) -eq 0 ]; then
|
||||
chown -R @DEFAULT_USER@:@DEFAULT_GROUP@ @ENGINE_LOGDIR@
|
||||
chown -R @DEFAULT_USER@:@DEFAULT_GROUP@ /etc/columnstore
|
||||
findcmd=`which find 2>/dev/null`
|
||||
findcmd=$(which find 2>/dev/null)
|
||||
if [ -n "$findcmd" ]; then
|
||||
if [[ $($findcmd @ENGINE_DATADIR@ -maxdepth 3 ! -user @DEFAULT_USER@ -exec echo {} \; -quit 2>/dev/null) ]]; then
|
||||
echo "At least one file is not owned by @DEFAULT_USER@ in @ENGINE_DATADIR@. Running chown..."
|
||||
|
Reference in New Issue
Block a user