Welcome
My name is Ulysses. Sr. Cloud Engineer at Cardinal Health.
About This Website
This is my static site based on Hugo.
My name is Ulysses. Sr. Cloud Engineer at Cardinal Health.
This is my static site based on Hugo.
xrdp is a package that allows another desktop to connect to another using the rdp desktop software. Install xrdp on the target desktop. sudo apt install xrdp Add a second user since you can’t use the default user. Use -m to create a home directory. sudo useradd -m john Give new user sudo access. This is optional, but is nice to have if running root commands. sudo usermod -a -G sudo john Set the user’s password. ...
I found a really nice gem that sets all external links to open to a new tab. It’s called jekyll-target-blank. To add, just run the following. Edit Gemfile and add this line. gem 'jekyll-target-blank' Edit the _config.yml file and add this line. plugins: - jekyll-target-blank Run bundle install. $ bundle install Because I’m running Jekyll in a docker container, I had to restart it. docker-compose stop docker-compose up -d Check your external links. They should open up to a new tab.
scp is an excellent utility for copying files to and from a server without the need for running a ftp server or some sort of file transfer service on the server. scp uses your existing ssh access to copy files to and from a server. You will need permissions to the remote server otherwise scp copy will fail. Whether pulling down a file or pushing a file to a server, scp can be invoked from a client regardless of file direction. You can copy a single file or multiple files. The examples below demonstrate this. ...
If you find yourself entering the same value multiple times in your Terraform script, you can save yourself some time by declaring local variables inside a locals block and reuse them throughout your script or module. Here’s a locals block. locals { project = "your_project_id" hostname = "your_hostname" machine_image = "your_machine_image" } Once the local variables are declared, you can reuse them anywhere and as many times as you want in your Terraform script or module. ...
Here’s a simple Bash script that displays how long it takes for a script to run from beginning to end. This is perfect tool for long running scripts that run for hours, and where you need to know much time it took to run from beginning to end. This is ideal for a script that you’ll run unattended. #!/bin/bash log='elapse.log' >$log start() { start=$(date) begin=$(date +%s) echo 'Start: '$start | tee -a $log } stop() { stop=$(date) end=$(date +%s) echo 'Stop: '$stop | tee -a $log elapse=$((end-begin)) } show_time() { num=$elapse min=0 hour=0 day=0 if((num>59));then ((sec=num%60)) ((num=num/60)) if((num>59));then ((min=num%60)) ((num=num/60)) if((num>23));then ((hour=num%24)) ((day=num/24)) else ((hour=num)) fi else ((min=num)) fi else ((sec=num)) fi echo "$day"d "$hour"h "$min"m "$sec"s | tee -a $log } script() { echo "running script now..." | tee -a $log sleep 10 } start script stop show_time In the example above, I’m running a script that echoes text and sleeps for 10s. Here’s the output. ...
I switched to a slightly different format in the home page to display the date first followed by the post titles. In addition to the format change, I wanted to truncate the titles that are longer than 40 characters to display only the first 40 characters followed by 3 dots or “…” at the end. The key to making this possible was to use Jekyll’s advanced filters, and in particular, using the truncate filter. Swapping the order of date and post titles was the easy part, but the key was using the truncate filter. ...
I recently bought a 2TB NVME SSD drive which I plan to install on my Linux Mint desktop. I have been taking a ton of pictures lately with my old Nikon D700 DSLR camera and I can use the extra space. Since the new drive is unformatted, here were the steps that I took to get it working on my desktop. This how-to assumes that I have installed the new NVME drive on your motherboard successfully. ...
If you have a disk drive, SSD or NVME storage device that need to be wiped clean, I recommend that you use the shred command. In this example, I’m cleaning up the contents of my NVME device at /dev/nvme0n1. sudo shred -v -n 1 --random-source=/dev/urandom -z /dev/nvme0n1 I’m using these options and their explanation. -v is verbose -n is the number of iterations. Mine is set to 1. You can increase it, but it can take hours. –random-source is set to /dev/urandom which is the kernel’s random number generator. -z means everything gets overwritten by zeros. Shred will make it nearly impossible to steal your data.
Here are input options that you can use in Bash. You can set variables within the script. You can pass the arguments via command line. You can prompt the user to input data. Or you create a script that incorporates all three. Remove comments if you want to set the variables in the script. Pass arguments via command line using the format provided. Or be prompted to enter all your arguments one at a time. # project="projectid" # instance="hostname" # zone="us-central1-c" # policy="hourly" # snapback=3 # Format (requires all 5 arguments): ./script.sh project host zone policy snapback # If no arguments are provided or less than 5 arguments, you will be prompted to enter your options. if [ -z "$project" ] || [ -z "$instance" ] || [ -z "$zone" ] || [ -z "$policy" ] || [ -z "$snapback" ]; then if [ "$#" -eq 5 ]; then project=$1 instance=$2 zone=$3 policy=$4 snapback=$5 else read -p "projectId : " project read -p "instance : " instance read -p "zone : " zone read -p "policy : " policy read -p "snapback : " snapback fi fi echo $project $instance $zone $policy $snapback
How to make a function call within a function in Bash. In my previous [post]({% post_url 2023-12-20-gcp-restore-boot-disk %}), I used several functions. We will call them in the main function below. main() { checkLogin displayHeader getDisks getSnaps read -p "Do you want to proceed with restore? Are you sure? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then stopServer detachDisks deleteDisks createDisks attachDisks setAutodelete startServer fi } main