Skip to content
lachlan edited this page Apr 26, 2022 · 14 revisions

CLI

DEPRECIATED

Use the Ampache 5 CLI faq

Command line tools

Ampache ships with several scripts designed to be run from the command line which can be used to automate common management tasks. They are located in the bin/ directory of the distribution. To run them, you should be able to do php <path to script> [options...] in your favourite terminal environment. There are other, unmaintained scripts in the bin directory that are not documented here and should be approached with caution.

bin/catalog_update.inc

Tool for updating catalogs. You might consider running it from cron.

Usage: catalog_update.inc [-n CATALOG NAME] [-t CATALOG TYPE] [-h|-m|-c|-v|-a|-g|-u|-i|-o] (!)
        Default behaviour is to do all on local catalog(s)

-h      This help message
-n      Name of Catalog (optional)
-t      Type of Catalog (optional)
-m      Temporarily deactivates PHP memory limit (1)
-c      Cleans Catalogs from orphaned entries
-v      Verifies Catalog entries and updates them if related files have new information
-a      Adds new media to Catalogs
-g      Gathers media Art
-u      Update artist information in db and fetch similar artists from last.fm Make sure lastfm_api_key is set in your configuration file
-i      Imports playlists
-o      Optimizes database tables (2)

Examples:

  • to clean (remove missing files from catalog): php /var/www/ampache/bin/catalog_update.inc -c
  • to clean+verify+add+gather (ampache update): php /var/www/ampache/bin/catalog_update.inc -c -v -a -g

bin/channel_run.inc

Start a specific channel and stream the same music to several clients. Ideal to host a web radio.

Usage: channel_run.inc [-c {CHANNEL ID}|-p {PORT}|-v]
-c {CHANNEL ID}      Channel id to start
-p {PORT}            Listening port, default get an available port automatically
-v                   Verbose

bin/print_tags.inc

Given a file, this script will run through Ampache's metadata gathering process then print out both the raw and processed results. Very useful for troubleshooting metadata problems.

bin/websocket_run.inc

Run the Ampache WebSocket server (necessary for Broadcasts and remote control Web Player features).

Usage: websocket_run.inc [-p {PORT}|-v]
-p {PORT}            Listening port, default 8100
-v                   Verbose

bin/write_playlists.inc

Export playlists in different formats.

Usage: bin/write_playlists.inc <DIRNAME> <TYPE> [<EXT>]

Examples:

  • to export all playlists to xspf files: php bin/write_playlists.inc /var/local/playlists playlists xspf
  • to export all albums to m3u files: php bin/write_playlists.inc /var/local/playlists albums m3u
  • to export all artists to pls files: php bin/write_playlists.inc /var/local/playlists artists pls

bin/install/install_db.inc

Usage: install_db.inc [options]
        -U, --database-user                     MySQL Admin User
        -P, --database-password                 MySQL Admin Password
        -h, --database-host                     MySQL Hostname
        -d, --database-name                     MySQL Database Name
        -u, --ampache-database-user             MySQL Application Username
        -p, --ampache-database-pass             MySQL Application Password
        -w, --webpath                           Web path
        -f, --force                             Force installation

bin/install/update_db.inc

With no options, displays whether the database requires schema updates. To actually do the updates, run it with -u.

bin/install/add_user.inc

Usage: add_user.inc -u <username> [ -l <access level> ] [ -p <password ] [ -e <email> ] [ -w <website> ] [ -n <name> ]

bin/clean_art_table.inc

With no options, clean art that doesn't fit your min or max dimensions

Clone this wiki locally