• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for August 2022

Jekyll on Docker Container

August 30, 2022

Here’s how to run Jekyll in a Docker container.

mkdir blog
cd blog
docker run -v $(pwd):/site bretfisher/jekyll new .
docker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve

mkdir blog cd blog docker run -v $(pwd):/site bretfisher/jekyll new . docker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve

Another option is to use docker compose. Create a docker-compose.yml file.

version: 3.5
services:
  jekyll:
    image: bretfisher/jekyll-serve
    volumes:
      - .:/site
    ports:
      - '4000:4000'

version: 3.5 services: jekyll: image: bretfisher/jekyll-serve volumes: - .:/site ports: - '4000:4000'

Run Jekyll.

cd blog
docker-compose up -d

cd blog docker-compose up -d

Stop Jekyll.

cd blog
docker-compose down

cd blog docker-compose down

Filed Under: Linux Tagged With: container, docker, docker-compose, down, jekyll, up

Cleanup Stale CVS Snapshots

August 30, 2022

Here’s the script that looks mounts with stale file handles and removes them.

#!/bin/bash
file='/tmp/stale.txt'
df -h | grep Stale > $file
sed -i -e 's/df: ‘/'""'/g' $file
sed -i -e 's/’: Stale file handle/'""'/g' $file
while IFS= read -r line; do
  echo 'unmounting '$line
  umount $line
done < $file

#!/bin/bash file='/tmp/stale.txt' df -h | grep Stale > $file sed -i -e 's/df: ‘/'""'/g' $file sed -i -e 's/’: Stale file handle/'""'/g' $file while IFS= read -r line; do echo 'unmounting '$line umount $line done < $file

Filed Under: Linux Tagged With: bash, cvs, file, handles, snapshots, stale

Cleanup CVS Snapshot Volumes

August 30, 2022

How to unmount CVS snapshot volumes all at once using a Bash script. I ran into a scenario where I had to unmount 115 volumes. Instead of manually running umount on each one, I use the script below to unmount all 115 volumes. The script performs a grep for ‘.snapshot’ and then writes the results to a file. I then read the file line by line and perform unmount on each one.

#!/bin/bash
file='/tmp/snapshots.txt'
df -h | grep .snapshot | awk '{print $6}' > $file
while IFS= read -r line; do
  echo 'unmounting '$line
  umount $line
done < $file

#!/bin/bash file='/tmp/snapshots.txt' df -h | grep .snapshot | awk '{print $6}' > $file while IFS= read -r line; do echo 'unmounting '$line umount $line done < $file

Filed Under: Linux Tagged With: bash, cvs, snapshots, umount

Editors on Terminal

August 25, 2022

How to run editors from the Terminal.

Sublime, Visual Studio Code, Atom and Bluefish examples.

Open from the current directory.

subl .
code .
atom .
bluefish .

subl . code . atom . bluefish .

Open editor using path and file.

subl /etc/hosts
code /etc/hosts
atom /etc/hosts
bluefish /etc/hosts

subl /etc/hosts code /etc/hosts atom /etc/hosts bluefish /etc/hosts

Filed Under: Linux Tagged With: atom, bluefish, command line, editors, sublime, terminal, visual studio

Copy Directory Structure

August 25, 2022

Here’s how to copy a directory structure from one directory to another without the files.

Copy directory structure of DIR1 to DIR2.

find /DIR1 -type d > /tmp/dirs.txt
sed -i 's/DIR1/DIR2/' /tmp/dirs.txt 
xargs mkdir -p < /tmp/dirs.txt
chown -R USER:GROUP /DIR2

find /DIR1 -type d > /tmp/dirs.txt sed -i 's/DIR1/DIR2/' /tmp/dirs.txt xargs mkdir -p < /tmp/dirs.txt chown -R USER:GROUP /DIR2

Filed Under: Linux Tagged With: copy, directory, files, structure, without

Bash Spacebar Break

August 16, 2022

Here’s how to add breaks in your Bash scripts. The function is called spacebar.

function spacebar {
  echo 'Press spacebar to continue. Press Ctrl-C to exit.'
  stty -echo > /dev/null
  until read -r -n 1 -t 0.001 && [ "$REPLY" = ' ' ]; do abc=''; done
  stty echo > /dev/null
}
 
spacebar

function spacebar { echo 'Press spacebar to continue. Press Ctrl-C to exit.' stty -echo > /dev/null until read -r -n 1 -t 0.001 && [ "$REPLY" = ' ' ]; do abc=''; done stty echo > /dev/null } spacebar

You can call it multiple times in your script since it’s a function.

Filed Under: Linux Tagged With: bash, continue, hit, spacebar

Set Vim Colors Permanently

August 12, 2022

Here’s how to set Vim colors permanently.

vi ~/.vimrc

vi ~/.vimrc

Add the following.

highlight Normal ctermfg=white ctermbg=black

highlight Normal ctermfg=white ctermbg=black

Filed Under: Linux Tagged With: background, colors, foreground, permanent, vim

Press spacebar to continue

August 5, 2022

Here’s a little snippet of Bash code that waits for spacebar to be pressed to continue.

function spacebar {
  echo 'Press spacebar to continue. Press Ctrl-C to exit.'
  stty -echo > /dev/null
  until read -r -n 1 -t 0.001 && [ "$REPLY" = ' ' ]; do abc=''; done
  stty echo > /dev/null
}
echo 'Starting upgrade'
spacebar

function spacebar { echo 'Press spacebar to continue. Press Ctrl-C to exit.' stty -echo > /dev/null until read -r -n 1 -t 0.001 && [ "$REPLY" = ' ' ]; do abc=''; done stty echo > /dev/null } echo 'Starting upgrade' spacebar

Output

Starting upgrade
Press spacebar to continue. Or Ctrl-C to exit.

Starting upgrade Press spacebar to continue. Or Ctrl-C to exit.

If you press spacebar it will continue. Ctrl-C exits the program.

Filed Under: Linux Tagged With: bash, continue, spacebar, wait

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023