port activation through sh file

Issues related to configuring your network
Post Reply
jrgt_1976
Posts: 21
Joined: 2017/12/23 07:42:05
Location: Mexico

port activation through sh file

Post by jrgt_1976 » 2018/03/06 02:57:35

Hi fellas, it's me again...

I've been reading a lot about this topic and I can't seem to find a solution. I have this sh file that opens up a port, whenever I execute it, works.
What I can't achieve is to load it at startup, not boot startup, user startup. It works with java.
This fle has the function to start listening to this specific port for information exchange. So far so good. But, the problem comes up when this server has to be restarted, every user that uses this port can't establish communication.

If I execute this file, port 7000 comes up and listens. I already created a service, symlink, but nothing comes up.

sockets.service

[Unit]
Description = Sockets Servidor
After = network.target

[Service]
ExecStart = /usr/local/bin/arranca.sh
TimeoutStart = 1

[Install]
WantedBy = multi-user.target

If I enable the service, no error comes up. If I type systemctl status sockets.service (when it's already started):

● sockets.service - Sockets Servidor
Loaded: loaded (/etc/systemd/system/sockets.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2018-03-05 20:46:57 CST; 19s ago
Process: 5732 ExecStart=/usr/local/bin/arranca.sh (code=exited, status=0/SUCCESS)
Main PID: 5732 (code=exited, status=0/SUCCESS)

What am I missing? All I need is this file being executed in order to open up port 7000 without user intervention (once the user has logged in).

Even on "Startup Application Preferences" isn't working.
The file works, my concern is to make it run whenever the user logs in. This is useful because I don´t have to execute it everytime this server is restarted or when a power loss comes up.

Thanks in advance for your comments.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: port activation through sh file

Post by TrevorH » 2018/03/06 10:15:33

Why are you doing this? Why not just run firewall-cmd --add-port=7000/tcp and use the distro supplied tools to do the job?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jrgt_1976
Posts: 21
Joined: 2017/12/23 07:42:05
Location: Mexico

Re: port activation through sh file

Post by jrgt_1976 » 2018/03/07 17:56:28

Well, I already did.
The thing is this kind of setting is needed to receive certain data from customers, on both ends some java files are functioning to do this.
This applies to some scenarios where IT admins are absent and we need to make tests without touching server setting (not our linux servers).
It may look odd but it works just fine. The rule for port 7000 is already set, but it appears closed when you scan it from the outside.
By starting this sh file it opens up and we can start working, besides, it turns out to be useful because if we stop the process no one else can use this port.

Post Reply