install.sh
install.sh copied to clipboard
Failure to get current version
Updates could be risky, you can use the backup option # rocketchatctl backup, to create a backup of the rocketchat database first. Please check that you have enough space in your system to store the backup.
/usr/local/bin/rocketchatctl: line 898: [: 3.9.4: unary operator expected
Could not determine if updates available for RocketChat server.```
Problem is in the `get_rocketchat_current_version()` function
`cat /lib/systemd/system/rocketchat.service |grep PORT |awk -F= '{print $3}'` is wrong, the correct field on my system is `$8`...
A better solution is to use:
`PORT=$(perl -ne 'print $1 if /PORT=(\d+)/' /lib/systemd/system/rocketchat.service)`
or
`grep -Eo 'PORT=\S+' /lib/systemd/system/rocketchat.service | cut -d= -f2` but this might be less portable, not sure `-E` or/and `-o` are universally supported...
Hi @kurkale6ka
Can you show me the content of your /lib/systemd/system/rocketchat.service unit file?
@kurkale6ka Any updates on this?
I am also having the same issue (on a different line number though) this time on line 909:
root@rocket-chat-server-01:~# rocketchatctl check-updates
Updates could be risky, you can use the backup option # rocketchatctl backup, to create a backup of the rocketchat database first. Please check that you have enough space in your system to store the backup.
/usr/local/bin/rocketchatctl: line 909: [: 3.12.3: unary operator expected
Could not determine if updates available for RocketChat server.
here is the content of my /lib/systemd/system/rocketchat.service
[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.service mongod.service
[Service]
ExecStart=/usr/bin/node /opt/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=http://localhost:3000/ PORT=3000
[Install]
WantedBy=multi-user.target
It seems that get_rocketchat_current_version is not getting the current version correctly as $current_rocketchat_version is empty (I checked with an echo $current_rocketchat_version ) and I believe that the error is precisely in line 764 i.e. in in getting the PORT :
PORT=$(cat /lib/systemd/system/rocketchat.service |grep PORT |awk -F= '{print $3}')
This line depends a lot on the location of the PORT in MONGO_OPLOG_URL in /lib/systemd/system/rocketchat.service as it uses awk -F= '{print $3}' which means PORT should be at the correct position.
My fix is to replace the awk part with: something like sed 's/.*PORT=\([^][,[:space:]]*\).*/\1/':
PORT=$(cat /lib/systemd/system/rocketchat.service |grep PORT |sed 's/.*PORT=\([^][,[:space:]]*\).*/\1/')