I created this process to improve my record keeping while working on a Linux bash shell. It allows for one to take notes while on the command line as well as publish to WordPress for tidy and organized record keeping.
Features:
- Posts logs to WordPress from any Linux hosts.
- Log all CLI commands to syslog globally.
- Record literal notes to syslog.
- Privately post logs to WordPress via CLI.
- Posting of Subject from CLI to WP posts.
- Auto insert [hostname] into WordPress post subject.
- Auto remove undesired data from WP posts.
- Auto insert [shortcode] into WordPress posts.
Roadmap:
- Auto redact sensitive data on CLI WP post actions.
- Record file changes to syslog (fork tripwire).
- Post Categories to WordPress posts from CLI.
- Post Tags to WordPress posts from CLI.
Requirements:
- A self-hosted WordPress Installation.
- The free Twenty Fifteen Theme.
- FOSS Postie Plugin by Wayne Allen.
- FOSS SyntaxHilighter Evolved by Alex Mills.
- A pop3 mailbox (Postie to pull & DELETE emails).
- Logger via the util-linux package.
- Mailx via the mail-utils package.
- Rsyslog via rsyslog package.
- A bit of troysio microcode.
Steps:
- Install WordPress.
- Activate Twenty Fifteen Theme.
- Download/Activate SyntaxHilighter Evolved in plugins.
- Download/Activate Postie within plugins area.
- Configure Postie to fetch and posts PRIVATELY text only.
- Install mail-utils and util-linux packages on all Linux hosts.
- Create your CLI logging syslog service.
- Drop the following troysio microcode into e.g. /usr/local/bin/yourio and make it executable.
#!/bin/sh # Troy Perkins # https://troys.io # Note: Make sure to remove all "\"es from Shortcode lines before executing. I had to place them in order for this code to be published here due to surrounding bash shortcode in this post. #Host host=`hostname`; #Pop3 mailbox; mailb="your@email.com"; #Content file='/var/log/commands.log'; #file='/var/log/test.log'; #Shortcode shrtstart='\[\bash]'; shrtend='\[\/\bash]'; { echo $shrtstart; cat $file | cut -d':' --complement -s -f1,2,3,4 | sed 's/\ [^\ ]*$//'; echo $shrtend; } | uniq | mailx -s "[$host] $1" $mailb
Usage:
To take manual notes type a # sign then your note then hit enter:
root@crm:# # Here is an example of a manual note on the command line.
To send notes to WordPress:
root@crm:# troysio "Here is my subject"
Example Output:
vi /usr/bin/troysio vi /usr/bin/troysio-redact troysio "testing new cut" cat /var/log/commands.log | cut -d':' --complement -s -f1,2,3,4 vi /usr/bin/troysio vi /usr/bin/troysio-redact troysio "testing new cut" troysio uniq vi /usr/bin/troysio troysio uniq troysio | uniq vi /usr/bin/troysio vi /usr/bin/troysio-redact troysio "testing uniq" vi /usr/bin/troysio troysio "testing uniq" cat -A /var/log/commands.log cp /usr/bin/troysio /usr/bin/troysio-test vi /usr/bin/troysio-test troysio-test | cat -A troysio-test | sub(/\r$/,"") | cat -A troysio-test | cat -A # Here is an example of a manual note on the command line. # Hope you enjoy your note taking helper. # Cheers. troysio "here is my subject" # WordPress post made with above command with title [crm] < host and "here is my subject" on the title of post. # Joy
To view the actual post, which I’ve changed from Private to Public just for you go here: https://troys.io/crm-here-is-my-subject/
Leave a Reply