The target audience of this tool are small entities that need a url shortener. The shortened urls can be publicly resolved but only registered users can create short urls. Every registered user can see all shorted urls but only modify its own. Admin users can invite other accounts and edit everything that can be edited (also urls created by other accounts).
So in general this is more a shared short url bookmark webpage than a short url service.
A demo instance is running under https://demo.pslink.teilgedanken.de/app/
The Username and Password are both demo. Do not use this for any production use case as the database is wiped every 15 minutes. If your created links/users are suddenly missing this is due to such a database wipe.
-
Guests (no account):
- click on link, get redirected to the page
- error on invalid or deleted link
-
Users (regular account):
- view all existing links
- open and copy shortened and target links directly from list and edit views
- create and modify own links (including an optional internal comment)
- download qr-codes of the links (PNG 200x200, PNG 1000x1000, or SVG)
- inspect link target health status, check history, and live preview
- modify own "profile" settings
-
Admins (privileged account):
- everything from users
- modify all links
- list all users
- modify all profiles
- create new users
- make users administrators
- make administrators normal users
- export the SQLite database backup
-
Command line
- create and read from a
.envfile in the current directory - create and migrate the database
- vacuum the database to reclaim disk space (
pslink vacuum) - create an admin user
- run the webserver
- create and read from a
-
Service
- redirect according to the database
- periodic and on-demand health checks of link targets (keeping the last 14 checks per link)
- admin interface via wasm
You can most easily run the container with podman or docker. This will launch the pslink service in demo mode. So whenever the container is restarted everything is reset to the demo data.
If you want to run in production mode you will need to set up and persist the .env file and the links.db sqlite database. See the Container Documentation.
$ podman run ghcr.io/enaut/pslink:latestThe Pslink bundle can be downloaded from the latest release at: https://github.com/enaut/pslink/releases
Just extract the bundle where you like. A sample install might be:
# mkdir -p /opt/pslink
# cd /opt/pslink
# wget https://github.com/enaut/pslink/releases/latest/download/pslink-linux-x86_64-bundle.tgz
# tar -xf pslink-linux-x86_64-bundle.tgz
# /opt/pslink/pslink helpYou could now adjust your PATH or setup an alias or just call the binary with the full path /opt/pslink/pslink
cargo install pslink does not (yet) produce a working binary! Use the "install binary" or "build from source" approach
Checkout the git repository and within its directory issue the following commands. Internet is required and some packages will be installed during the process.
$ cargo install dioxus-cli
$ dx bundle --release --platform webIf that succeeds you should now be able to call Pslink. The binary is located at target/dx/pslink/release/web/pslink (or server). The directory target/dx/pslink/release/web/ can be moved wherever you want it to be.
SQLx uses the committed .sqlx query metadata during builds, independently of any DATABASE_URL in .env. After changing a checked SQL query or a migration, regenerate the metadata against a separate, freshly migrated development database using a matching version of sqlx-cli:
DATABASE_URL=sqlite:target/sqlx-prepare.db sqlx database create
DATABASE_URL=sqlite:target/sqlx-prepare.db sqlx migrate run
DATABASE_URL=sqlite:target/sqlx-prepare.db SQLX_OFFLINE=false cargo sqlx prepare -- --features serverRemove the temporary database before repeating this process so all migrations run on a fresh schema. Commit the resulting .sqlx changes along with the query or migration changes. Runtime databases still need their migrations applied; the server applies pending migrations at startup.
In the binary releases and in this README the server binary is named pslink.
To read the help and documentation of additional options call:
pslink helpTo get Pslink up and running use the commands in the following order:
-
pslink generate-envthis will generate a
.envfile in the current directory with the default settings. Edit this file to your liking. You can however skip this step and provide all the parameters via command line or environment variable. It is not recommended to providePSLINK_SECRETwith command line parameters as they can be read by every user on the system. -
pslink migrate-databasewill create a sqlite database in the location specified in the .env file.
-
pslink create-admincreate an initial admin user. As the page has no "register" function this is required to do anything useful. The command is interactive so you will be asked the username and password of the new admin user.
-
pslink runserverIf everything is set up correctly this command will start the service. You should now be able to go to your url at http://localhost/app/ and you should be presented with a login screen where you can login with the credentials you just created (use the username not the email).
If everything is already correctly set up just do pslink runserver to launch the server.
To update to a newer version:
- stop the service
- download and install or build the new binary
- run the server again
pslink runserver(pending database migrations on an existing database are applied automatically on startup; runningpslink migrate-databasemanually beforehand is optional)
For a list of options use pslink help. If the help does not provide enough clues please file an issue at: https://github.com/enaut/pslink/issues/new. Feel free to do so even for simple questions, comments or requests!
While there are probably millions of ways to set up Pslink as a service on a server, here is an example using systemd.
In this case a dedicated pslink user and group is used with the users home directory at /opt/pslink.
Some additional settings are in place to protect the system a little should anything go wrong.
- create the user
sudo adduser pslink --home-dir /opt/pslink
- create the directory and change its owner and permissions
sudo mkdir -p /opt/pslink sudo chown pslink:pslink /opt/pslink sudo chmod 700 /opt/pslink
- create the initial config file and database
cd /opt/pslink sudo -u pslink /opt/pslink/pslink generate-env sudo -u pslink /opt/pslink/pslink migrate-database sudo -u pslink /opt/pslink/pslink create-admin - create the systemd service file at
/etc/systemd/system/pslink.serviceand adjust it to your liking:cat /etc/systemd/system/pslink.service [Unit] Description=Pslink the Urlshortener Documentation=https://github.com/enaut/Pslink Wants=network.target After=network.target [Service] User=pslink Group=pslink EnvironmentFile=-/opt/pslink/.env ProtectHome=true ProtectSystem=full PrivateDevices=true NoNewPrivileges=true PrivateTmp=true InaccessibleDirectories=/root /sys /srv /media -/lost+found ReadWriteDirectories=/opt/pslink WorkingDirectory=/opt/pslink ExecStart=/opt/pslink/pslink runserver [Install] WantedBy=multi-user.target - start and install the service
sudo systemctl enable --now pslink - check the log file for errors:
sudo systemctl status pslink sudo journalctl -u pslink

