2 How it all works
zrep edited this page 2024-04-06 00:26:29 +02:00

How it all works

Introduction

zpi is, in its essence, a concept and a client/server system. zpi stands for Zrep Package Installer.

The zpi client connects to the zrep web server to request information and then performs operations on the client side.

The zrep client

The zpi client is written for the Zsh shell and I've tried to utilize the power of Zsh as much as I could throughout the script. There are, of course, something better left to other tools, such as parsing JSON with jq, the use of grep and sed and a selection of download toos such as curl, wget or wget2.

When you first launch zpi it tries to access different files and if they're not present, you'll be told to run zpi init. This command will create and populate ~/.zreprc which is the configuration file. It will also create, per default, a directory in ~/.zrep which holds functions, themes, a temp directory and the scripts you will install later.

zrep init will download 2 files from the Github repository. 1. zini which is an INI reader also written in Zsh. 2. ~/.zrep/themes/classic. This is the color theme for the messages the zrep client displays.

The website and the rePanel Dashboard

The website contains a few PHP scripts that the zpi client connects to.

For example, when you run zpi install kekePower/tohtml it connects to the webserver (/getver.php) which responds with a JSON tree that zpi parses and inserts the version to the download URL (/download/kekePower/tohtml/version). The download script does a few things. First off it checks if the script is present in the database and has the published key set and if it is, it updates the download count for the respective script. Then it sends the request to Github to actually download the requested package.

The reason I am using Github for this is to save bandwidth on my connection.

Another example is when you run zpi search 'search term'. This also connects to the webserver (/find.php) which searches through the database and presents a list of packages, if there are more than one, with the package name, a description and the URL to the package on the zrep website.

The rePanel Dashboard

rePanel is the dashboard for creators, people who registers for an account. This is the place they have complete access to their scripts and statistics. Since the dashboard is at its beginning stage, quite a lot of functionality is still not complete and will be completed over time. I do not have a time frame for this, but will do my best to make it happen. You can also help out if you want to. Send me a message if you have suggestions or want to help me refine the website and/or rePanel.

When a new script is created, it is added to the database but is not yet published. This is done in a separate step.

The publishing step is done in two steps. The first step is when the creator publishes the script. The files are written to disk in a temporary directory and are waiting there to be moved to the Github repository.

This move is done using a shell script that runs, at the moment, every hour. This will change over time as more and more scripts are added by more and more creators.