Skip to content

Repository files navigation

AGS Script Library

A collection of PowerShell and web scripts to make IT work easier. Scripts are self-hosted on your own web server so you can run them on any machine with a single one-liner, no files to copy around.


Requirements

  • A Linux web server running Apache or Nginx with PHP 8.0+
  • git installed on the server
  • Root / sudo access for the initial install

Quick install

SSH into your server and run:

curl -fsSL https://raw.githubusercontent.com/Leander-Andersen/public-ags-scripts/main/install.sh | sudo bash

This uses all defaults: web root /var/www/html, scripts folder scripts.


Full install with options

If you want to customise the paths, download the script first and pass arguments:

curl -fsSL https://raw.githubusercontent.com/Leander-Andersen/public-ags-scripts/main/install.sh -o install.sh
sudo bash install.sh --webroot /var/www/html --scripts-folder scripts

Parameters

Parameter Default Description
--webroot /var/www/html Absolute path to your web server's document root.
--scripts-folder scripts Name of the folder the scripts will live in under the web root. This becomes the URL path segment, e.g. https://yourserver.com/scripts/. Must be alphanumeric (hyphens and underscores allowed, no spaces).
--user auto-detected The OS user your web server runs as (www-data, apache, nginx). The installer tries to detect this automatically — only pass it if detection fails.
--branch main Which git branch to install from. Use main for stable releases.

What the installer does

  1. Clones the repository into <webroot>/<scripts-folder>/ If the destination already exists, it does a hard reset to the latest commit instead.
  2. Copies the file browser (index.php, viewer.php, globalVariables.php) from the repo to the web root so they serve from https://yourserver.com/.
  3. Sets file ownership on everything it touched to the web server user.
  4. Prints the URL for the next step.

After install — run setup.php

Open a browser and go to:

http://your-server/<scripts-folder>/setup.php

Enter three values:

  • Script domain — the domain or subdomain this server is reachable at (e.g. scripts.yourdomain.com). No https://, no trailing slash.
  • Folder name — must match the --scripts-folder you used during install (e.g. scripts).
  • Admin password — used to gate update.php so random people can't trigger updates. Leave blank to have a strong random one generated for you — you'll see it once on the success page, save it somewhere safe. Lost it? SSH in, delete setup.lock, re-run setup.php.

Setup will scan every script in the library, show you a diff of every line that will change, and wait for you to confirm before writing anything. Once applied it:

  • Rewrites all <SCRIPT_DOMAIN> and <SCRIPT_FOLDER> placeholders across every .ps1, .php, .sh, and other text file in the library — including this README, so all URLs below become real copy-paste links
  • Renames the scripts folder on disk to match what you entered
  • Saves your settings to .setup-config.json (domain, folder, bcrypt'd admin password hash) so updates can re-apply them automatically
  • Creates setup.lock to prevent accidental re-runs

After setup your scripts are live:

https://<SCRIPT_DOMAIN>/<SCRIPT_FOLDER>/SetDefaultBrowser/SetDefaultBrowser.ps1
https://<SCRIPT_DOMAIN>/<SCRIPT_FOLDER>/Hextract/Hextract.ps1
https://<SCRIPT_DOMAIN>/<SCRIPT_FOLDER>/PnS/PnS.ps1

Updating

Once the library is set up, visit:

https://<SCRIPT_DOMAIN>/<SCRIPT_FOLDER>/update.php

You'll be prompted for the admin password you set during setup.php. Once logged in, the updater will:

  1. Fetch the latest commits from GitHub
  2. Show you a summary of what changed
  3. Pull the changes with a hard reset to the selected branch
  4. Automatically re-apply your saved domain and folder settings from .setup-config.json

You do not need to re-run setup.php or the installer after an update — your configuration is preserved.

Updating from a version that pre-dates the admin password

If .setup-config.json doesn't contain an admin_pw_hash field (older deployments), update.php will tell you so and refuse to run. To migrate:

  1. SSH in
  2. rm <webroot>/<scripts-folder>/setup.lock
  3. Visit setup.php in a browser — the form pre-fills with your existing domain/folder
  4. Set an admin password (or leave blank to auto-generate)
  5. Submit → apply → save the password
  6. update.php is now usable with the new password

Locking down .setup-config.json

The scripts folder ships an Apache .htaccess that denies HTTP access to .setup-config.json, setup.lock, .htaccess itself, and any *.bak / *.log files. Apache picks it up automatically.

Nginx users — Apache .htaccess files are ignored by Nginx; add the equivalent to your server block:

location ~ /\.(setup-config\.json|htaccess)$ { deny all; }
location ~ /setup\.lock$                      { deny all; }
location ~ \.(bak|log)$                       { deny all; }

The password hash is bcrypt'd before being written, so even if the file were to leak the plaintext is not directly recoverable — but defense in depth is cheap, and the file has no business being HTTP-fetchable.


Custom error pages

The installer deploys a webroot-level .htaccess plus two themed error pages — both OverPinku, both with falling sakura, click-burst hearts, and a link back to the file browser. Any URL on the domain that triggers the matching status lands on the themed page instead of Apache's default.

Status Page Fires on
404 /404.php URLs that don't resolve to a real file
403 /403.php URLs blocked by .htaccess deny rules (.setup-config.json, setup.lock, *.bak, *.log, etc.)

Nginx equivalent (add to your server block):

error_page 404 /404.php;
error_page 403 /403.php;
location = /404.php { internal; }
location = /403.php { internal; }

If your webroot already has a .htaccess for another tool, the install / updater step overwrites it. Merge the ErrorDocument lines into your existing rules instead.


File browser

The installer places a file browser at the web root (index.php) so visiting https://yourserver.com/ shows a navigable directory listing of all your scripts. Features:

  • Click any folder to browse into it
  • Click any .md file to render it as formatted markdown (via viewer.php)
  • Click any .ps1 or other file to download / view it directly
  • Dark, light, and OverPinku theme with toggle button (preference saved per-browser)

Available scripts

Script What it does
SetDefaultBrowser Sets the default browser on Windows via an interactive menu or silent parameters. Supports Chrome, Firefox, Brave, and removal.
Hextract Generates a hardware hash for Windows Autopilot enrollment.
PnS Retrieves the product name and serial number from a laptop (useful for warranty lookups).

Branch structure

Branch Purpose
main Stable releases — what the installer pulls by default
experimental New features that work but aren't fully hardened yet
Feature branches Work in progress

About

Some small scripts I have created to make life easier at work.

Topics

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages