Skip to content

Instantly share code, notes, and snippets.

@PrintNow
Created December 30, 2025 09:08
Show Gist options
  • Select an option

  • Save PrintNow/02a2530392a23364012e4eedaffabb0d to your computer and use it in GitHub Desktop.

Select an option

Save PrintNow/02a2530392a23364012e4eedaffabb0d to your computer and use it in GitHub Desktop.

GOST SysVinit Service Script

A universal SysVinit init script for GOST (GO Simple Tunnel) that works on systems without systemd.

Features

  • Compatible with legacy SysVinit systems
  • No dependency on LSB functions
  • Automatic process management with PID file
  • Logging support
  • Works on Debian, Ubuntu, CentOS, Alpine, and other Linux distributions

Installation

1. Install GOST

Download and install GOST binary:

# Download latest GOST (adjust version as needed)
wget https://github.com/ginuerzh/gost/releases/download/v2.11.5/gost-linux-amd64-2.11.5.gz
gunzip gost-linux-amd64-2.11.5.gz
chmod +x gost-linux-amd64-2.11.5
sudo mv gost-linux-amd64-2.11.5 /usr/local/bin/gost

2. Install the init script

# Download the script
sudo curl -o /etc/init.d/gost https://gist.githubusercontent.com/YOUR_USERNAME/YOUR_GIST_ID/raw/gost

# Make it executable
sudo chmod +x /etc/init.d/gost

3. Configure GOST arguments

Edit the script to set your GOST configuration:

sudo nano /etc/init.d/gost

Modify the DAEMON_ARGS line:

# Example: Local SOCKS5 proxy
DAEMON_ARGS="-L :1080"

# Example: With forwarding chain
DAEMON_ARGS="-L :1080 -F socks5://proxy.example.com:1080"

# Example: Use config file
DAEMON_ARGS="-C /etc/gost/gost.yaml"

# Example: Empty (will use default or config file)
DAEMON_ARGS=""

4. Enable auto-start on boot

Debian/Ubuntu:

sudo update-rc.d gost defaults

CentOS/RHEL:

sudo chkconfig --add gost
sudo chkconfig gost on

Alpine Linux:

sudo rc-update add gost default

Universal method (rc.local):

echo '/etc/init.d/gost start' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local

Usage

Service commands

sudo service gost start      # Start GOST
sudo service gost stop       # Stop GOST
sudo service gost restart    # Restart GOST
sudo service gost status     # Check status

View logs

tail -f /var/log/gost.log

Check if proxy is working

# Test SOCKS5 proxy
curl -x socks5://127.0.0.1:1080 https://www.google.com

# Test HTTP proxy
curl -x http://127.0.0.1:8080 https://www.google.com

# Check listening ports
netstat -tlnp | grep gost
# or
ss -tlnp | grep gost

Configuration Examples

Example 1: Simple local SOCKS5 proxy

DAEMON_ARGS="-L :1080"

Example 2: HTTP proxy with authentication

DAEMON_ARGS="-L admin:password@:8080"

Example 3: Forward through Shadowsocks

DAEMON_ARGS="-L :1080 -F ss://chacha20-ietf-poly1305:password@server:port"

Example 4: Use YAML config file

Create /etc/gost/gost.yaml:

services:
  - name: service-0
    addr: :1080
    handler:
      type: auto
    listener:
      type: tcp

Then set:

DAEMON_ARGS="-C /etc/gost/gost.yaml"

Troubleshooting

Service says "not running" but GOST is actually running

Check if GOST is really running:

ps aux | grep gost
netstat -tlnp | grep 1080

If it's running, the script's detection might need adjustment for your system.

Check logs for errors

tail -20 /var/log/gost.log

Manually test GOST command

/usr/local/bin/gost -L :1080

Permission issues

Ensure the script has proper permissions:

sudo chmod +x /etc/init.d/gost

Uninstall

Remove auto-start

Debian/Ubuntu:

sudo update-rc.d -f gost remove

CentOS/RHEL:

sudo chkconfig gost off
sudo chkconfig --del gost

Alpine Linux:

sudo rc-update del gost default

Remove files

sudo service gost stop
sudo rm /etc/init.d/gost
sudo rm /var/run/gost.pid
sudo rm /var/log/gost.log

License

This script is provided as-is under the MIT License.

Links

Contributing

Feel free to submit issues or pull requests to improve this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment