-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
9,281 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
ARG LIBRENMS_VERSION=24.9.1 | ||
FROM mcr.microsoft.com/devcontainers/php:1-8.1-bullseye | ||
|
||
COPY php.ini /usr/local/etc/php/conf.d/99-php.ini | ||
|
||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get install -y mariadb-client \ | ||
acl curl fping git graphviz imagemagick mtr-tiny nmap rrdtool \ | ||
snmp snmpd whois unzip iputils-ping \ | ||
python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN apt update \ | ||
&& apt install -y zlib1g-dev g++ git libicu-dev zip libzip-dev libpq-dev \ | ||
&& docker-php-ext-configure zip \ | ||
&& docker-php-ext-install zip | ||
|
||
RUN apt update \ | ||
&& apt install -y libsnmp-dev \ | ||
&& docker-php-ext-configure snmp --with-snmp \ | ||
&& docker-php-ext-install snmp | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
libfreetype-dev \ | ||
libjpeg62-turbo-dev \ | ||
libpng-dev \ | ||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | ||
&& docker-php-ext-install -j$(nproc) gd | ||
|
||
RUN docker-php-ext-install mysqli pdo pdo_mysql sockets | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
WORKDIR "/workspaces/${localWorkspaceFolderBasename}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
{ | ||
"name": "codespace-librenms", | ||
"dockerComposeFile": [ | ||
"docker-compose.yml" | ||
], | ||
"service": "app", | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
"remoteUser": "vscode", | ||
"remoteEnv": { | ||
"PATH": "${containerEnv:PATH}:${containerEnv:LIBRENMS_FOLDER}", | ||
"LOCAL_WORKSPACE_FOLDER": "/workspaces/${localWorkspaceFolderBasename}", | ||
"LIBRENMS_FOLDER": "/var/www/html/librenms" | ||
}, | ||
"containerEnv": { | ||
"LOCAL_WORKSPACE_FOLDER": "/workspaces/${localWorkspaceFolderBasename}", | ||
"LIBRENMS_FOLDER": "/var/www/html/librenms" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"xdebug.php-debug", | ||
"bmewburn.vscode-intelephense-client", | ||
"ms-azuretools.vscode-docker", | ||
"p1c2u.docker-compose", | ||
"ryannaddy.laravel-artisan", | ||
"amiralizadeh9480.laravel-extra-intellisense", | ||
"georgykurian.laravel-ide-helper", | ||
"mtxr.sqltools-driver-mysql" | ||
], | ||
"settings": { | ||
"php.suggest.basic": false, | ||
"php.validate.enable": true, | ||
"php.validate.run": "onSave", | ||
"artisan.location": [ | ||
"${containerEnv:LIBRENMS_FOLDER}/artisan" | ||
], | ||
"intelephense.environment.documentRoot": "${localWorkspaceFolder}", | ||
"intelephense.environment.includePaths": [ | ||
"${containerEnv:LIBRENMS_FOLDER}" | ||
], | ||
"sqltools.connections": [ | ||
{ | ||
"driver": "mysql", | ||
"name": "librenms", | ||
"server": "${containerEnv:DB_HOST}", | ||
"port": 3306, | ||
"database": "${containerEnv:DB_NAME}", | ||
"user": "${containerEnv:DB_USER}", | ||
"password": "${containerEnv:DB_PASSWORD}", | ||
"multipleStatements": true | ||
} | ||
], | ||
"launch": { | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch LibreNMS", | ||
"type": "php", | ||
"request": "launch", | ||
"envFile": "${containerEnv:LIBRENMS_FOLDER}/.env", | ||
"cwd": "${containerEnv:LIBRENMS_FOLDER}", | ||
"program": "${containerEnv:LIBRENMS_FOLDER}/artisan", | ||
"args": [ | ||
"serve" | ||
], | ||
"port": 9000, | ||
"serverReadyAction": { | ||
"pattern": "Server running on", | ||
"uriFormat": "http://localhost:8000", | ||
"action": "openExternally" | ||
} | ||
}, | ||
{ | ||
"name": "Listen for XDebug", | ||
"type": "php", | ||
"request": "launch", | ||
"port": 9003 | ||
} | ||
], | ||
"compounds": [] | ||
}, | ||
"tasks": { | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "artisan", | ||
"type": "shell", | ||
"command": "php", | ||
"args": [ | ||
"artisan", | ||
"${input:command}" | ||
], | ||
"problemMatcher": [], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"cwd": "${containerEnv:LIBRENMS_FOLDER}" | ||
}, | ||
{ | ||
"label": "Artisan Publish Views", | ||
"type": "shell", | ||
"command": "php", | ||
"args": [ | ||
"artisan", | ||
"vendor:publish", | ||
"--tag=views" | ||
], | ||
"problemMatcher": [], | ||
"cwd": "${containerEnv:LIBRENMS_FOLDER}" | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
"type": "pickString", | ||
"id": "command", | ||
"description": "Choose an artisan command", | ||
"options": [ | ||
"cache:clear", | ||
"config:cache", | ||
"config:clear", | ||
"db:seed", | ||
"migrate", | ||
"migrate:fresh", | ||
"migrate:install", | ||
"migrate:refresh", | ||
"migrate:reset", | ||
"migrate:rollback", | ||
"migrate:status", | ||
"optimize", | ||
"route:cache", | ||
"route:clear", | ||
"view:clear" | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
} | ||
}, | ||
"postCreateCommand": "sudo mkdir -p /var/log/xdebug && sudo chmod -R 777 /var/log/xdebug", | ||
"postStartCommand": "bash .devcontainer/postStart.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
x-env-global: &env-global | ||
- &MYSQL_DATABASE "librenms" | ||
- &MYSQL_USER "librenms" | ||
- &MYSQL_PASSWORD "asupersecretpassword" | ||
- &TZ "UTC" | ||
- &PUID "1000" | ||
- &PGID "1000" | ||
- &LIBRENMS_VERSION "24.9.1" | ||
|
||
x-envlibrenms: &envlibrenms | ||
MEMORY_LIMIT: "256M" | ||
MAX_INPUT_VARS: "1000" | ||
UPLOAD_MAX_SIZE: "16M" | ||
OPCACHE_MEM_SIZE: "128" | ||
REAL_IP_FROM: "0.0.0.0/32" | ||
REAL_IP_HEADER: "X-Forwarded-For" | ||
LOG_IP_VAR: "remote_addr" | ||
CACHE_DRIVER: "redis" | ||
SESSION_DRIVER: "redis" | ||
REDIS_HOST: "redis" | ||
LIBRENMS_SNMP_COMMUNITY: "librenmsdocker" | ||
LIBRENMS_WEATHERMAP: "true" | ||
LIBRENMS_WEATHERMAP_SCHEDULE: "*/5 * * * *" | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
image: librenms | ||
command: sleep infinity | ||
volumes: | ||
- ../..:/workspaces:cached | ||
tty: true | ||
environment: | ||
<<: *envlibrenms | ||
TZ: *TZ | ||
PUID: *PUID | ||
PGID: *PGID | ||
DB_HOST: "127.0.0.1" | ||
DB_NAME: *MYSQL_DATABASE | ||
DB_USER: *MYSQL_USER | ||
DB_PASSWORD: *MYSQL_PASSWORD | ||
DB_TIMEOUT: "60" | ||
LIBRENMS_VERSION: *LIBRENMS_VERSION | ||
|
||
network_mode: service:db | ||
|
||
db: | ||
image: mariadb:10.11 | ||
command: | ||
- "mysqld" | ||
- "--innodb-file-per-table=1" | ||
- "--lower-case-table-names=0" | ||
- "--character-set-server=utf8mb4" | ||
- "--collation-server=utf8mb4_unicode_ci" | ||
volumes: | ||
- "db:/var/lib/mysql" | ||
environment: | ||
TZ: *TZ | ||
MARIADB_RANDOM_ROOT_PASSWORD: "yes" | ||
MYSQL_DATABASE: *MYSQL_DATABASE | ||
MYSQL_USER: *MYSQL_USER | ||
MYSQL_PASSWORD: *MYSQL_PASSWORD | ||
|
||
redis: | ||
image: redis:7.2-alpine | ||
environment: | ||
TZ: *TZ | ||
|
||
snmpsim: | ||
build: | ||
context: snmpsim | ||
image: snmpsim | ||
ports: | ||
- "1161:1161" | ||
volumes: | ||
- ./snmpsim/data:/usr/snmpsim/data | ||
networks: | ||
default: | ||
aliases: | ||
- snmpsim2 | ||
|
||
volumes: | ||
db: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[PHP] | ||
expose_php = On | ||
error_reporting = E_ALL | ||
display_errors = On | ||
report_memleaks = On | ||
html_errors = On | ||
auto_globals_jit = Off | ||
max_input_time = 60 | ||
max_execution_time = -1 | ||
post_max_size = 100M | ||
upload_max_filesize = 100M | ||
variables_order = EGPCS | ||
output_buffering = 4096 | ||
register_argc_argv = On | ||
request_order = GP | ||
short_open_tag = Off | ||
precision = 14 | ||
max_input_nesting_level = 32 | ||
implicit_flush = Off | ||
serialize_precision = 14 | ||
ignore_user_abort = On | ||
realpath_cache_size = 4096k | ||
zend.enable_gc = On | ||
zend.exception_ignore_args = On | ||
log_errors = On | ||
ignore_repeated_errors = Off | ||
default_mimetype = "text/html" | ||
default_charset = "UTF-8" | ||
enable_dl = Off | ||
file_uploads = On | ||
max_file_uploads = 20 | ||
allow_url_fopen = On | ||
allow_url_include = 0 | ||
default_socket_timeout = 60 | ||
user_agent = "" | ||
|
||
[opcache] | ||
opcache.jit = disable | ||
|
||
[xdebug] | ||
xdebug.discover_client_host = 1 | ||
xdebug.log = /var/log/xdebug/xdebug.log | ||
xdebug.log_level=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
LIBRENMS_VERSION=${LIBRENMS_VERSION:-24.9.1} | ||
|
||
# env LIBRENMS_FOLDER is the folder where librenms is installed | ||
LIBRENMS_FOLDER_BASE=$(dirname $(realpath $LIBRENMS_FOLDER)) | ||
|
||
cd $LIBRENMS_FOLDER_BASE || exit 1 | ||
|
||
echo "Cloning librenms version $LIBRENMS_VERSION into $LIBRENMS_FOLDER" | ||
|
||
git clone https://github.com/librenms/librenms.git --branch $LIBRENMS_VERSION --depth 1 --single-branch librenms | ||
|
||
cd librenms || exit 1 | ||
|
||
php ./scripts/composer_wrapper.php install --no-dev --prefer-dist --no-interaction --no-progress --no-suggest | ||
|
||
cp config.php.default config.php | ||
|
||
echo "DB_HOST=127.0.0.1" | tee -a .env | ||
echo "DB_DATABASE=$DB_NAME" | tee -a .env | ||
echo "DB_USER=$DB_USER" | tee -a .env | ||
echo "DB_PASSWORD=$DB_PASSWORD" | tee -a .env | ||
echo "LIBRENMS_USER=vscode" | tee -a .env | ||
echo "APP_URL=/" | tee -a .env | ||
# I could not get output to stderr to work | ||
# for outputing in the terminal when running "artisan sevrve" | ||
echo "LOG_CHANNEL=stack" | tee -a .env | ||
echo "LOG_LEVEL=debug" | tee -a .env | ||
echo "APP_DEBUG=true" | tee -a .env | ||
sed -i '/INSTALL=true/d' .env | ||
|
||
echo \$config[\'db_host\'] = \'127.0.0.1\'\; | tee -a config.php | ||
echo \$config[\'db_user\'] = \'$DB_USER\'\; | tee -a config.php | ||
echo \$config[\'db_pass\'] = \'$DB_PASSWORD\'\; | tee -a config.php | ||
echo \$config[\'db_name\'] = \'$DB_NAME\'\; | tee -a config.php | ||
|
||
echo "Setting up librenms" | ||
|
||
# seed the database | ||
php artisan db:seed --force | ||
|
||
# load .env as environment variables | ||
# .env does not work for some reason | ||
export $(grep -v '^#' .env | xargs) | ||
php lnms --force -n migrate || true | ||
php lnms -n user:add -p librenms -r admin -n librenms >/dev/null || true # add user if not exists | ||
php lnms -n user:add -p admin -r admin -n admin >/dev/null || true # add user if not exists | ||
|
||
echo "Adding snmpsim device" | ||
php lnms -n device:add -r 1161 -2 -c demo -- snmpsim >/dev/null || true # add device if not exists | ||
php lnms -n device:add -r 1161 -2 -c testing -- snmpsim2 >/dev/null || true # add device if not exists | ||
|
||
composer config repositories.local '{"type": "path", "url": "'"${LOCAL_WORKSPACE_FOLDER}"'", "options": {"symlink": true}}' --file composer.json | ||
|
||
if [ -f "${LOCAL_WORKSPACE_FOLDER}/composer.json" ]; then | ||
PACKAGE_NAME=$(jq -r '.name' "${LOCAL_WORKSPACE_FOLDER}/composer.json") | ||
if [ -n "$PACKAGE_NAME" ]; then | ||
echo "Adding $PACKAGE_NAME to librenms" | ||
FORCE=1 composer require "$PACKAGE_NAME" | ||
fi | ||
fi | ||
|
||
php artisan route:clear | ||
|
||
echo -e "Environment setup done. Librenms installed in ${LIBRENMS_FOLDER}.\nHappy coding!" | ||
|
||
php artisan vendor:publish --provider="DotMike\Devicefields\Providers\DeviceFieldsProvider" --force | ||
php lnms --force -n migrate || true | ||
|
||
#php artisan cache:clear | ||
#php artisan route:clear | ||
#php artisan view:clear |
Oops, something went wrong.