I have a Linux server with some config files that need to be updated by the user, I would like the ability to add entries to these files from a web UI instead of a user editing the files directly.
I will be using bootstrap for the UI.
But I would like to know what would be the approach or best technology to use to keep these files up-to-date or manage their contents.
I have a good understanding of PHP and always used databases for storing information - but I'm lost about how to tackle this.
File one is called jobs.yml looks like this
#Convert Audio
job1:
label: Convert to Text to MP3
watch: /home/media/convert_audio/to_mp3
events: ['write_close', 'move_to']
recursive: false
command: /home/media/bin/to_mp3 "$filename"
job12:
label: Convert to Text to WAV
watch: /home/media/convert_audio/to_wav
events: ['write_close', 'move_to']
recursive: false
command: /home/media/bin/to_wav "$filename"
File two is actually a collection of bash files or scripts (I guess this could be templated)
#!/bin/bash
o="$1"
o="${o##*/}"
o="${o%.*}"
ffmpeg -i $1 -qscale 0 "/home/media/convert_videos/converted/$o.mpg"
mv "$1" /home/media/convert_videos/processed/
I would ultimately like to Add/Remove and edit entries
For yml files, there are PHP functions that permit to easily manage them : PHP.net. You can also found libraries which add more features.
For bash files, they are like other files and you can read/write content with PHP file functions (PHP.net). But you will have to write your own logic to append/remove new lines.
It maybe a good idea to use a database to store all lines which have to be in each files. You will can rebuild all file content from DB (it will be simpler to add/remove lines).
To finish, take care of what your users write in your bash files, it's a potential security breach.