Goshorly is an open-source URL shortener written in Go. In this tutorial, we will guide you through the steps of installing goshorly on NetBSD.
Before starting with the installation process, make sure that you have the following prerequisites:
The first step is to clone the goshorly repository from the Git server. Open the terminal and run the following command:
git clone https://gitea.hackmi.ch/Phil/goshorly.git
This command will fetch the latest source code of goshorly and clone it on your system.
After cloning the repository, navigate into the project directory using the terminal:
cd goshorly
Now, you can build the project using the following command:
go build
This command will compile the source code and generate a binary file in the same directory.
The next step is to configure the application. The configuration file is located in the conf/
directory. You can copy the example configuration file and make changes according to your needs using the following command:
cp conf/example.json conf/config.json
Now, open the configuration file using a text editor and make the necessary changes.
After configuring the application, you can run it using the following command:
./goshorly -config conf/config.json
This command will start the goshorly application, and it will be available at http://localhost:8080
.
To start goshorly automatically on system startup, you can create a service for it. Create a new file called goshorly.service
in the /etc/rc.d/
directory and paste the following content:
#!/bin/sh
#
# PROVIDE: goshorly
# REQUIRE: NETWORKING
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable goshorly:
#
# goshorly_enable="YES"
#
. /etc/rc.subr
name="goshorly"
rcvar=${name}_enable
command="/usr/local/bin/goshorly"
command_args="-config /path/to/config"
pidfile="/var/run/${name}.pid"
start_cmd="goshorly_start"
stop_cmd="goshorly_stop"
status_cmd="goshorly_status"
goshorly_start() {
${command} ${command_args} &
echo $! >> ${pidfile}
}
goshorly_stop() {
pkill -F ${pidfile}
rm -f ${pidfile}
}
goshorly_status() {
pgrep -qf ${command} > /dev/null 2>&1 && echo "Running" || echo "Not Running"
}
load_rc_config ${name}
run_rc_command "$1"
Replace /path/to/config
with the path to your configuration file.
After creating the file, make it executable using the following command:
chmod +x /etc/rc.d/goshorly.service
Now, you can start the service using the following command:
service goshorly start
This command will start the goshorly service, and it will automatically start on system boot.
Congratulations, you have successfully installed goshorly on NetBSD. You can now use it as your URL shortener.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!