I have the need to run an Azure Devops Agent as a systemD. Typcially I would just run it inside a container. But due to requirements on this system and pipeline I am unable to simply run inside a container. The belows assumes you have an agent already setup. Lets get started.
First, lets go over the structure of a systemd service file.
There are three important sections. They are [Unit], [Service], and [Install]. The extension is .service and we can make comments with the hash symbol(#).
[Unit]
Description=Devops Service
After=multi-user.target
[Service]
ExecStart=/home/[username]/myagent/run.sh
WorkingDirectory=/home/[username]/myagent/
User=opc
Group=opc
Restart=always
Type=simple
[Install]
WantedBy=default.target
The [Unit] section helps describe the service and when to start it. In this case we want to ensure the network is up before starting the service. You can include an [...]
There will be times that Windows Offline files will give you problems. Such as not showing the correct files. You can cause Windows to reinitialize the cache by changing the following registry options.
Locate the registry subkey using regedit.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CSC
setting Start to 4[...]
MongoDB is not your typical database. It is a NoSQL variant that stores data in an document based format. There are several advantages and disadvantages that I will not go into details in this post. In this document we will go over how to quickly setup a MongoDB instance inside an docker container along with adding data and running a query against it.
sudo docker pull mongo
Docker containers are volatile. This means that when you shutdown the container any changes to any of the files inside a container are lost. The default Mongo container mounts the databases under the /data/db path. We can map that path with a path on the physicals host with the below command.
Create a directory to store your data with the following command.
sudo mkdir -p /data/mongo
When you run the container you will want to map the /data/mongo directory path with /data/db using the following command.[...]
The first that that I programmed in Rust was before version 1 was released. Rust is currently sitting at version 1.46. I wanted a quick project to review the language in the current form. The project I decided on was to write a very basic C2.
The code below launches a TCP stream that connects to a netcat session and starts a command session that redirects the STDIO and STDERR streams.
This project allowed great insight into how threading worked in Rust. Below is the code that I ended up with. Again, this is very basic and the structure could be cleaned up.
#![allow(unused)]
#[macro_use]
extern crate lazy_static;
use std::process::ChildStdin;
use std::process::Command;
use std::io::Write;
use std::process::Stdio;
use std::str;
use std::io::{BufRead, BufReader, BufWriter};
use std::thread;
use std::time;
use std::io::Read;
use std::sync::{Arc, Mutex};
use std::io::{stdin,stdout};
use std::net::TcpStream;
use std::io::prelude::*;
use tokio::io::split;
struct tcpStructure {
[...]