etc/init.d/vncserver: line 33: [: =: unary operator expected - vnc

While starting and stopping the vncserver . i am facing the following error.But, the service is running fine.SO do any one have the similar kind of error on vnc server startup script.
"
/etc/init.d/vncserver restart
Shutting down VNC server: 9:shashikanth.bussa
/etc/init.d/vncserver: line 33: [: =: unary operator expected
start() {
[ "$EUID" != "0" ] && exit 4
# Source networking configuration.
. /etc/sysconfig/network
"

Its because of /etc/sysconfig/network file entry.
We need to make sure the option NETWORKING=yes.
Then restart the vnc service.

Related

Still connect 22 ssh port when using gpinitsystem command of Greenplum withing different ssh port of CentOS7

I want to install Greenplum in CentOS7.9 which is changed default ssh port to 10022. I changed 'gpssh-exkeys' script to add '-p 10022' for all of ssh command and add '-P 10022' for all of scp command. And run it is ok.
Then I changed '/usr/local/greenplum-db/lib/python/gppylib/commands/base.py' script to add '-p 10022' in a ssh command line.
# Escape " for remote execution otherwise it interferes with ssh
cmd.cmdStr = cmd.cmdStr.replace('"', '\\"')
cmd.cmdStr = "ssh -p 10022 -o StrictHostKeyChecking=no -o ServerAliveInterval=60 " \
"{targethost} \"{gphome} {cmdstr}\"".format(targethost=self.targetHost,
gphome=". %s/greenplum_path.sh;" % self.gphome,
cmdstr=cmd.cmdStr)
But I got the error that present still try to connent port 22 when run 'gpinitsystem'.
[gpadmin#mdw ~]$ gpinitsystem -c /home/gpadmin/gpinitsystem_config --locale=zh_CN -h /home/gpadmin/seg_hosts
20220303:21:55:40:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, please wait...
20220303:21:55:40:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Reading Greenplum configuration file /home/gpadmin/gpinitsystem_config
20220303:21:55:40:005293 gpinitsystem:mdw:gpadmin-[INFO]:-No DATABASE_NAME set, will exit following template1 updates
20220303:21:55:40:005293 gpinitsystem:mdw:gpadmin-[INFO]:-MASTER_MAX_CONNECT not set, will set to default value 250
20220303:21:55:40:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, Completed
20220303:21:55:40:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing multi-home checks, please wait...
.ssh: connect to host sdw1 port 22: Connection refused
.ssh: connect to host sdw2 port 22: Connection refused
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Configuring build for multi-home array
/usr/local/greenplum-db-6.19.3/bin/gpinitsystem: line 630: ((: REMAINDER=2 % 0: division by 0 (error token is "0")
/usr/local/greenplum-db-6.19.3/bin/gpinitsystem: line 631: ((: MULTIPLE=2 / 0: division by 0 (error token is "0")
/usr/local/greenplum-db-6.19.3/bin/gpinitsystem: line 632: [: -ne: unary operator expected
/usr/local/greenplum-db-6.19.3/bin/gpinitsystem: line 632: [: -eq: unary operator expected
/usr/local/greenplum-db-6.19.3/bin/gpinitsystem: line 640: [: -gt: unary operator expected
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing multi-home checks, Completed
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Building primary segment instance array, please wait...
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Building group mirror array type , please wait...
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Checking Master host
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-[INFO]:-Checking new segment hosts, please wait...
ssh: connect to host sdw1 port 22: Connection refused
/usr/local/greenplum-db-6.19.3/bin/gpinitsystem: line 704: [: -eq: unary operator expected
ssh: connect to host mdw port 22: Connection refused
/usr/local/greenplum-db-6.19.3/bin/gpinitsystem: line 732: [: -lt: unary operator expected
ssh: connect to host mdw port 22: Connection refused
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-[WARN]:-Postgres version does not match. [postgres (Greenplum Database) 6.19.3 build commit:33e10eef63ae25aeb33afbefdda46b6367353800 Open Source != ]
20220303:21:55:41:005293 gpinitsystem:mdw:gpadmin-Postgres version does not match Script Exiting!
And I didn't find official documents, https://docs.greenplum.org/, for guiding how to install withing the different ssh port.
Thank you!
Do not modify delivered utilities. Recommend leveraging ~gpadmin/.ssh/config specifying Port for your hosts. All Greenplum utilities should honor settings in that file.
Example ~gpadmin/.ssh/config where all hosts are known as sdw1-pri, sdw2-pri and so on:
Host sdw*-pri
Port 10022
Can you specify the 10022 port in /etc/sshd_config and try again.
gpinitsystem internally calling REMOTE_EXECUTE_AND_GET_OUTPUT function which is part of <install_dir>/bin/lib/gp_bash_functions.sh file.
Currently gp_bash_functions.sh has below entries.
SSH=`findCmdInPath ssh`
if [ x"$TRUSTED_SHELL" = x"" ]; then TRUSTED_SHELL="$SSH"; fi
I think you may need to change the if condition like below
if [ x"$TRUSTED_SHELL" = x"" ]; then TRUSTED_SHELL="$SSH -p 10022"; fi
Thank you Greg Spiegelberg. Show my ~gpadmin/.ssh/config:
Host mdw
HostName mdw
Port 10022
Host smdw
HostName smdw
Port 10022
Host sdw1
HostName sdw1
Port 10022
Host sdw2
HostName sdw2
Port 10022
Priority of ssh config: specified parameter for command > .ssh/config > /etc/ssh/ssh_config

bash string comparison not working as expected - how to fix

I am trying to check if a program is installed on a linux system by comparing command output with an expected output. I expect the program not to be present and so if program is abc then I should see:
bash: abc: command not found
But instead I am getting this output:
Shell for this session: bash
./checkprogs.sh: line 17: [: too many arguments
addgroup feature enabled test 1
./checkprogs.sh: line 15: tftp: command not found
./checkprogs.sh: line 17: [: too many arguments
tftp feature enabled test 2
2 tests performed
Here is the bash code:
ourshell="/bin/bash"
ourshell=${ourshell#*bin/}
echo "Shell for this session: $ourshell"
counter=1
# list of programs we want to test if available
progs='addgroup tftp'
for prog in $progs
do
expected="$ourshell: $prog: command not found"
#echo "$expected"
progoutput=$($prog -h)
#echo "prog output is: $progoutput"
if [ $expected != $progoutput ]
then
echo "test failed"
fi
echo "$prog feature enabled test $counter"
((counter++))
done
((counter--))
echo "$counter tests performed"
How can I fix this?
On the system I am working on, the shell is bash and addgroup is present but tftp is not.
Please note that I am on an embedded platform and "expect" is not installed. Assume minimal linux installation.
EDIT:
had to add space after [ and before ] - but even after fixing that still doesn't work as expected.
EDIT:
sorry I am new to bash scripting...
If I quote the strings inside [ ] and add 2>&1 to progoutput then code looks like this:
progoutput=$($prog -h 2>&1) # line 15
if [ "$expected" != "$progoutput" ] # line 17
and just so anyone can try this:
progs='ls invalidxxx' # line 9
then output is:
Shell for this session: bash
test failed
ls feature enabled test 1
test failed
invalidxxx feature enabled test 2
2 tests performed
actual method of string comparison
if [ "$expected" != "$progoutput" ]
or
if [[ $expected != $progoutput ]]

Error: Wildfly dead but pid file exists

When I tried to restart wildfly webserver it kept giving these errors
Stopping wildfly: kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
/etc/init.d/wildfly: line 142: [: -eq: unary operator expected
/etc/init.d/wildfly: line 142: [: -eq: unary operator expected
/etc/init.d/wildfly: line 142: [: -eq: unary operator expected
/etc/init.d/wildfly: line 142: [: -eq: unary operator expected
When I tried to check the status by
sudo service wildfly status
The output is:
wildfly dead but pid file exists
seems like I need to delete PID file so that I can restart it.
I had to delete the /run/wildfly/wildfly.pid and start the service again. For me this was because the system crashed.

shell script to automatically restart tomcat if stopped

I am using a shell script to start tomcat server if it is not running. I am running this script in cronjob to check it frequently. This is my script
#! /bin/sh
SERVICE=/etc/init.d/tomcat7
STOPPED_MESSAGE="Tomcat Servlet Engine is not running."
if [ "`$SERVICE status`" -eq "$STOPPED_MESSAGE" ]; then
$SERVICE start
fi
But whenever I run this script, it gives me an error. If tomcat is not running then the error is :
[: ILLEGAL NUMBER : * Tomcat Servlet Engine is not running.]
And if tomcat is running the error is :
[: ILLEGAL NUMBER : * Tomcat Servlet Engine is running with pid 6130.]
I think the error is related to $SERVICE status but I am unable to resolve it. I am a new bee to shell scripting. Please help me out.
I cannot move forward until I resolve this issue.
-eq expects 2 integers for comparison (see man test). You should use = there for strings.
Or, could you be more tolerant about output from the script?
if $SERVICE status | grep -q "not running"; then
$SERVICE start
fi
Of course it would be much better to use a process monitoring tool like monit or supervisor.

installing trousers for tpm emulator

I have installed tpm emulator successfully. I get this error
* Starting Trusted Computing daemon tcsd /etc/init.d/trousers: 32: [: /dev/tpm: unexpected operator [fail]
invoke-rc.d: initscript trousers, action "start" failed.
dpkg: error processing trousers (--configure):
subprocess installed post-installation script returned error exit status 2
E: Sub-process /usr/bin/dpkg returned an error code (1)
when executing
sudo apt-get install tpm-tools libtspi-dev
The answer to that particular error message is a broken line in the given script /etc/init.d/trousers.
The offending line 32:
31:
32: if [ ! -e /dev/tpm* ]
33: then
gets expanded to:
if [ ! -e /dev/tpm /dev/tpm0 ]
Which provokes an error. Changing that line to something like:
31:
32: if [ ! -e /dev/tpm ] && [ ! -e /dev/tpm0 ]
33: then
should at least make the script work.

Resources