Skip to main content
All CollectionsStoreHivenet cloud
How can I run the Hivenet Agent as a service on Linux?
How can I run the Hivenet Agent as a service on Linux?

Optimize server resources by setting up Hivenet agent as a system service on a Linux server. This guide will help you install and manage it.

Thanasis Karavasilis avatar
Written by Thanasis Karavasilis
Updated over a month ago

This guide applies to server administrators, IT professionals, and technically inclined individuals who use Linux servers.

📘Instructions

Prerequisites:

Download and extract the latest Hivenet agent for Linux from hivenet.com.

Benefits of hive-agent as a systemd service:

  • Persistence: Continues running after reboots or logouts.

  • Management: Easy to manage and monitor with systemd.

  • Security: Isolates the process, enhancing server security.

1. Installation of hive-agent:

  • Move the extracted hive-agent binary to /usr/local/bin:

sudo cp hive-agent /usr/local/bin/hive-agent
  • Set the appropriate permissions:

sudo chmod 755 /usr/local/bin/hive-agent
  • Verify the installation:

hive-agent version

2. Setting up a User Account for hive-agent:

  • Switch to the hive-agent-user account:

sudo su - hive-agent-user
  • Set up the configuration file:

    • Create the .hive directory:

mkdir ~/.hive
  • Generate the default configuration file:

/usr/local/bin/hive-agent config init
  • (Optional) Modify the config.yaml file for custom configurations.

3. Authenticate with your Hivenet account:

  • Run the hive-agent contribute command (start with 5 GB or more):

/usr/local/bin/hive-agent contribute 5
  • Complete the authentication process using the provided URL in a web browser.

  • Exit the hive-agent-user session:

exit

4. Setting up hive-agent as a systemd Service:

  • Create a systemd service file:

sudo nano /etc/systemd/system/hive-agent.service
  • Add the following configuration, replacing XX with the GB to contribute:

[Unit]
Description=Hive Agent Service
After=network.target

[Service]
Type=simple
User=hive-agent-user
ExecStart=/usr/local/bin/hive-agent contribute XX

[Install]
WantedBy=default.target
  • Reload systemd:

sudo systemctl daemon-reload
  • Start the hive-agent service:

sudo systemctl start hive-agent
  • Enable the service to start on boot:

sudo systemctl enable hive-agent
  • Check the service status:

sudo systemctl status hive-agent

Stopping and removing the hive-agent service:

1. To stop the service:

sudo systemctl stop hive-agent
sudo systemctl disable hive-agent

2. To remove the service and hive-agent:

  • Remove the systemd service file:

sudo rm /etc/systemd/system/hive-agent.service
  • Reload systemd:

sudo systemctl daemon-reload
  • Remove the hive-agent binary:

sudo rm /usr/local/bin/hive-agent
  • (Optional) Remove the hive-agent-user and its directory:

sudo userdel -r hive-agent-user
  • (Optional) Remove the .hive directory:

rm -rf ~/.hive

By following these steps, you can effectively contribute your server's unused resources to the hive network, ensuring optimal utilization and performance.

Did this answer your question?