Added a way to reset the admin password. fixes #209

This commit is contained in:
emeric
2022-03-12 13:39:33 +01:00
parent 1ea6163260
commit e99c9c8c17
+11 -40
View File
@@ -12,33 +12,25 @@
* [Deploy on non root path](#deploy-on-non-root-path) * [Deploy on non root path](#deploy-on-non-root-path)
* [Reverse proxy settings](#reverse-proxy-settings) * [Reverse proxy settings](#reverse-proxy-settings)
- [Run](#run) - [Run](#run)
# Installation # Installation
## Docker ## Docker
_Docker_ images are available, please see detailed instructions on https://hub.docker.com/r/epoupon/lms. _Docker_ images are available, please see detailed instructions on https://hub.docker.com/r/epoupon/lms.
## Debian Buster packages ## Debian Buster packages
_Buster_ packages are provided for _amd64_ and _armhf_ architectures. _Buster_ packages are provided for _amd64_ and _armhf_ architectures.
As root, trust the following debian package provider and add it in your list of repositories: As root, trust the following debian package provider and add it in your list of repositories:
```sh ```sh
wget -O - https://debian.poupon.dev/apt/debian/epoupon.gpg.key | apt-key add - wget -O - https://debian.poupon.dev/apt/debian/epoupon.gpg.key | apt-key add -
echo "deb https://debian.poupon.dev/apt/debian buster main" > /etc/apt/sources.list.d/epoupon.list echo "deb https://debian.poupon.dev/apt/debian buster main" > /etc/apt/sources.list.d/epoupon.list
``` ```
To install or upgrade _LMS_: To install or upgrade _LMS_:
```sh ```sh
apt update apt update
apt install lms apt install lms
``` ```
The _lms_ service is started just after the package installation, run by a dedicated _lms_ system user.</br> The _lms_ service is started just after the package installation, run by a dedicated _lms_ system user.</br>
Please refer to [Deployment](#deployment) for further configuration options. Please refer to [Deployment](#deployment) for further configuration options.
## From source ## From source
__Note__: this installation process and the default values of the configuration files have been written for _Debian Buster_. Therefore, you may have to adapt commands and/or paths in order to fit to your distribution. __Note__: this installation process and the default values of the configuration files have been written for _Debian Buster_. Therefore, you may have to adapt commands and/or paths in order to fit to your distribution.
### Build dependencies ### Build dependencies
__Notes__: __Notes__:
* a C++17 compiler is needed * a C++17 compiler is needed
@@ -49,12 +41,9 @@ apt-get install g++ cmake libboost-program-options-dev libboost-system-dev libav
__Notes__: __Notes__:
* libpam0g-dev is optional (only for using PAM authentication) * libpam0g-dev is optional (only for using PAM authentication)
* libstb-dev can be replaced by libgraphicsmagick++1-dev (the latter will likely use more RAM) * libstb-dev can be replaced by libgraphicsmagick++1-dev (the latter will likely use more RAM)
You also need _Wt4_, which is not packaged yet on _Debian_. See [installation instructions](https://www.webtoolkit.eu/wt/doc/reference/html/InstallationUnix.html).</br> You also need _Wt4_, which is not packaged yet on _Debian_. See [installation instructions](https://www.webtoolkit.eu/wt/doc/reference/html/InstallationUnix.html).</br>
No optional requirement is needed, except openSSL if you plan not to deploy behind a reverse proxy (which is not recommended). No optional requirement is needed, except openSSL if you plan not to deploy behind a reverse proxy (which is not recommended).
### Build ### Build
Get the latest stable release and build it: Get the latest stable release and build it:
```sh ```sh
git clone https://github.com/epoupon/lms.git lms git clone https://github.com/epoupon/lms.git lms
@@ -66,80 +55,69 @@ cmake .. -DCMAKE_BUILD_TYPE=Release
__Notes__: __Notes__:
* you can customize the installation directory using `-DCMAKE_INSTALL_PREFIX=path` (defaults to `/usr/local`). * you can customize the installation directory using `-DCMAKE_INSTALL_PREFIX=path` (defaults to `/usr/local`).
* you can customize the image library using `-DIMAGE_LIBRARY=<STB|GraphicsMagick++>` * you can customize the image library using `-DIMAGE_LIBRARY=<STB|GraphicsMagick++>`
```sh ```sh
make make
``` ```
__Note__: you can use `make -jN` to speed up compilation time (N is the number of compilation workers to spawn). __Note__: you can use `make -jN` to speed up compilation time (N is the number of compilation workers to spawn).
### Installation ### Installation
__Note__: the commands of this section require root privileges. __Note__: the commands of this section require root privileges.
```sh ```sh
make install make install
``` ```
Create a dedicated system user: Create a dedicated system user:
```sh ```sh
useradd --system --group lms useradd --system --group lms
``` ```
Copy the configuration files: Copy the configuration files:
```sh ```sh
cp /usr/share/lms/lms.conf /etc/lms.conf cp /usr/share/lms/lms.conf /etc/lms.conf
cp /usr/share/lms/lms.service /lib/systemd/system/lms.service cp /usr/share/lms/lms.service /lib/systemd/system/lms.service
``` ```
Create the working directory and give it access to the _lms_ user: Create the working directory and give it access to the _lms_ user:
```sh ```sh
mkdir /var/lms mkdir /var/lms
chown lms:lms /var/lms chown lms:lms /var/lms
``` ```
To make _LMS_ run automatically during startup: To make _LMS_ run automatically during startup:
```sh ```sh
systemctl enable lms systemctl enable lms
``` ```
### Upgrade ### Upgrade
To upgrade _LMS_ from sources, you need to update the master branch and rebuild/install it: To upgrade _LMS_ from sources, you need to update the master branch and rebuild/install it:
```sh ```sh
cd build cd build
git pull git pull
make make
``` ```
Then using root privileges: Then using root privileges:
```sh ```sh
make install make install
systemctl restart lms systemctl restart lms
``` ```
# Deployment # Deployment
__Note__: don't forget to give the _lms_ user read access to the music directory you want to scan. __Note__: don't forget to give the _lms_ user read access to the music directory you want to scan.
## Configuration ## Configuration
_LMS_ uses a configuration file, installed by default in `/etc/lms.conf`. It is recommended to edit this file and change relevant settings (listen address, listen port, working directory, Subsonic API activation, deployment path, ...). _LMS_ uses a configuration file, installed by default in `/etc/lms.conf`. It is recommended to edit this file and change relevant settings (listen address, listen port, working directory, Subsonic API activation, deployment path, ...).
All other settings are set using the web interface (user management, scan settings, transcode settings, ...). All other settings are set using the web interface (user management, scan settings, transcode settings, ...).
If a setting is not present in the configuration file, a hardcoded default value is used (the same as in the [default configuration file](conf/lms.conf)) If a setting is not present in the configuration file, a hardcoded default value is used (the same as in the [default configuration file](conf/lms.conf))
## Authentication backend ## Authentication backend
You can define which authentication backend to be used thanks to the `authentication-backend` option: You can define which authentication backend to be used thanks to the `authentication-backend` option:
* `internal` (default): _LMS_ uses an internal database to store users and their associated passwords (salted and hashed using [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt)). Only the admin user can create, edit or remove other users. * `internal` (default): _LMS_ uses an internal database to store users and their associated passwords (salted and hashed using [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt)). Only the admin user can create, edit or remove other users.
* `PAM`: the user/password authentication request is forwarded to PAM (see the default [PAM configuration file](conf/pam/lms) provided). * `PAM`: the user/password authentication request is forwarded to PAM (see the default [PAM configuration file](conf/pam/lms) provided).
* `http-headers`: _LMS_ uses a configurable HTTP header field, typically set by a reverse proxy to handle [SSO](https://en.wikipedia.org/wiki/Single_sign-on), to extract the login name. You can customize the field to be used using the `http-headers-login-field` option. * `http-headers`: _LMS_ uses a configurable HTTP header field, typically set by a reverse proxy to handle [SSO](https://en.wikipedia.org/wiki/Single_sign-on), to extract the login name. You can customize the field to be used using the `http-headers-login-field` option.
__Note__: the first created user is the admin user __Note__: the first created user is the admin user
## `internal` backend: reset admin password
Open the the database file located in `/var/lms/lms.db` using `sqlite3`:
```sh
sqlite3 /var/lms/lms.db
```
Now force reset the password of the admin user to `adminadmin`:
```sqlite3
UPDATE user SET password_salt="sliIgHUpEoAlBMquivH4VzKXbSzexlvS", password_hash="$2y$07$a0vnQUbGTV/DZyDqOizvbOdCaytNjDhkOPcGoBZup4V0MRKDzOpEG" WHERE id=1;
.quit
```
## Deploy on non root path ## Deploy on non root path
If you want to deploy on non root path (e.g. https://mydomain.com/newroot/), you have to set the `deploy-path` option accordingly in `lms.conf`. If you want to deploy on non root path (e.g. https://mydomain.com/newroot/), you have to set the `deploy-path` option accordingly in `lms.conf`.
As static resources are __not__ related to the `deploy-path` option, you have to perform the following steps if you want them to be on a non root path too: As static resources are __not__ related to the `deploy-path` option, you have to perform the following steps if you want them to be on a non root path too:
* Create a new intermediary `newroot` directory in `/usr/share/lms/docroot` and move everything in it. * Create a new intermediary `newroot` directory in `/usr/share/lms/docroot` and move everything in it.
* Symlink `/usr/share/lms/docroot/newroot/resources` to `/usr/share/Wt/resources`. * Symlink `/usr/share/lms/docroot/newroot/resources` to `/usr/share/Wt/resources`.
@@ -149,12 +127,9 @@ wt-resources = "" # do not comment the whole line
docroot = "/usr/share/lms/docroot/;/newroot/resources,/newroot/css,/newroot/images,/newroot/js,/newroot/favicon.ico";` docroot = "/usr/share/lms/docroot/;/newroot/resources,/newroot/css,/newroot/images,/newroot/js,/newroot/favicon.ico";`
deploy-path = "/newroot/"; # ending slash is important deploy-path = "/newroot/"; # ending slash is important
``` ```
If you use nginx as a reverse proxy, you can simply replace `location /` with `location /newroot/` to achieve the same result. If you use nginx as a reverse proxy, you can simply replace `location /` with `location /newroot/` to achieve the same result.
## Reverse proxy settings ## Reverse proxy settings
_LMS_ is shipped with an embedded web server, but it is recommended to deploy behind a reverse proxy. You have to set the _behind-reverse-proxy_ option to _true_ in the `lms.conf` configuration file. _LMS_ is shipped with an embedded web server, but it is recommended to deploy behind a reverse proxy. You have to set the _behind-reverse-proxy_ option to _true_ in the `lms.conf` configuration file.
Here is an example to make _LMS_ properly work on _myserver.org_ using _nginx_: Here is an example to make _LMS_ properly work on _myserver.org_ using _nginx_:
``` ```
server { server {
@@ -183,16 +158,12 @@ server {
} }
} }
``` ```
# Run # Run
```sh ```sh
systemctl start lms systemctl start lms
``` ```
Log traces can be accessed using journactl: Log traces can be accessed using journactl:
```sh ```sh
journalctl -u lms.service journalctl -u lms.service
``` ```
To connect to _LMS_, just open your favorite browser and go to `http://localhost:5082`
To connect to _LMS_, just open your favorite browser and go to http://localhost:5082