Dev Server Automation
hi all, tis been a while. recently i've been furthering my rust knowledge and developing a vim plugin for rust crate management, Virgo. you can check it out here. this project has taken up a lot of my time and alas, i have neglected my blog. so today its time to end that neglect and dive in to what i have been working on over the last week and that is using the power of my Compute Module 5 Dev Server to optimize said project.

My CM5 Dev Server, housed in a generic abs enclosure.
Compute Module 5
the subject in question. this is a 4gb cm5 hooked up to the official io board with a 2280 128gb nvme drive which is connected to my local network over ethernet. it's on 24/7, tinkering away, mostly backing up data and hosting my local git server but it also has the power to automate builds and after realizing a rookie mistake (more later) i decided to automate the now lengthy build process with bash, cron and email notifications using smtp.
Rookie error
we all make them. mine was the sudden realization i was only building and releasing for x86_64, lol. duh. other architectures are available. so this now required building openssl from source for each architecture.. after a few hours of trying to get rustc and linux to play ball, finally by actively selecting each compiler in the shell (CC=) before the compilation of each architecure, i was ready to go.
Bash
now i needed to create an automation script that looped over 3 different architectures, x86_64, aarch64 and armv7 as these are the most common for linux. this was easy enough but then i had the absolutely genius idea of using the mail command to send a build report when it was complete. horror ensued.

snippet of my cross compile script
smtp hell
i had a horrible time configuring smtp. the end issue was using an icloud account that was linked to gmail. for some reason googles smtp server did not like it. it took a few hours and several failed attempts before i started from scratch and generated a new google account in order for it to work however it was finally fully configured, emails sent after each build or even each fail, with the subject of the email denoting build status and also some fun but important stats such as build time, temp and cpu load in the email body.

nightly build script, with mail command and system stats
cron job
the final hurdle! i love finally putting a script into cron, makes it feel finished. simple usage of crontab -e and the usual syntax means i now have builds for virgo over three architectures running every night at 2:00am, after a build a report is generated into a log file, attached to the email and sent. while i was here, i whipped up a few more scripts that run at different times, linting with clippys pedantic mode happens at 2:30, tests are run at 2:45:am and an overall system health report of the cm5 happens at 3am. all results are sent to me instantly via email, making my life a lot easier.

crontab, with scripts executing at 2, 230, 245 and 3am respectively
final thoughts
automation is king in the current, vast and high paced world of development. having builds, linting and tests run while you sleep is a game changer and this is just the start of it. we could have scripts execute on a commit using hooks with our local git server, run automated analysis on project changes, lifecycle, code quality or errors, utilize docker and kubernetes with bash and cron to automate containerized builds in a dedicated environment... the options are endless. plus, bash scripting is fun and an extremely useful skill in your toolkit, so automation also makes for good practice.
until next time,
Dru x