1 import config = require('config')
3 import { database as db } from './database'
4 import { CONFIG } from './constants'
6 // Some checks on configuration files
7 function checkConfig () {
8 if (config.has('webserver.host')) {
9 let errorMessage = '`host` config key was renamed to `hostname` but it seems you still have a `host` key in your configuration files!'
10 errorMessage += ' Please ensure to rename your `host` configuration to `hostname`.'
18 // Check the config files
19 function checkMissedConfig () {
20 const required = [ 'listen.port',
21 'webserver.https', 'webserver.hostname', 'webserver.port',
22 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
23 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews',
24 'admin.email', 'signup.enabled', 'transcoding.enabled', 'transcoding.threads'
28 for (const key of required) {
29 if (!config.has(key)) {
37 // Check the available codecs
38 function checkFFmpeg (callback) {
39 const Ffmpeg = require('fluent-ffmpeg')
41 Ffmpeg.getAvailableCodecs(function (err, codecs) {
42 if (err) return callback(err)
43 if (CONFIG.TRANSCODING.ENABLED === false) return callback(null)
45 const canEncode = [ 'libx264' ]
46 canEncode.forEach(function (codec) {
47 if (codecs[codec] === undefined) {
48 return callback(new Error('Unknown codec ' + codec + ' in FFmpeg.'))
51 if (codecs[codec].canEncode !== true) {
52 return callback(new Error('Unavailable encode codec ' + codec + ' in FFmpeg'))
60 function clientsExist (callback) {
61 db.OAuthClient.countTotal(function (err, totalClients) {
62 if (err) return callback(err)
64 return callback(null, totalClients !== 0)
68 function usersExist (callback) {
69 db.User.countTotal(function (err, totalUsers) {
70 if (err) return callback(err)
72 return callback(null, totalUsers !== 0)
76 // ---------------------------------------------------------------------------