Author Archives: kenno

How to remove a copr repository in Fedora

This is just a quick note to remind myself how to remove a Copr repository. What’s a Copr?

“Copr (Cool Other Package Repo) is a Fedora project to help make building and managing third party package repositories easy.” – https://fedoraproject.org/wiki/Category:Copr.

Why do I want to remove it? One of the Copr repo I added a while back seemed to be no longer working, so I wanted to remove it.

# dnf update --refresh
Failed to synchronize cache for repo 'tcg-themes', disabling.
Last metadata expiration check: 0:00:00 ago on Fri 08 Dec 2017 11:12:45 AM AEDT.
Dependencies resolved.
Nothing to do.
Complete!

To list all repos on Fedora (27):

# dnf repolist
Last metadata expiration check: 0:05:59 ago on Fri 08 Dec 2017 11:12:45 AM AEDT.
repo id                    repo name                                      status
*fedora                    Fedora 27 - x86_64                             54,801
google-chrome              google-chrome                                       3
tcg-themes                 Copr repo for themes owned by tcg                  23
*updates                   Fedora 27 - x86_64 - Updates                    6,420

To list just the Corp-repositories:

# dnf copr list
tcg/themes

And finally, to remove the above repo, tcg/themes:

# dnf copr remove tcg/themes
Repository successfully removed.
# dnf update
Last metadata expiration check: 5:18:23 ago on Fri 08 Dec 2017 11:12:45 AM AEDT.
Dependencies resolved.
Nothing to do.
Complete!

Ref: http://dnf-plugins-core.readthedocs.io/en/latest/copr.html

How to unban IP from PF firewall

This post is probably more relevant to my use case of PF firewall running on FreeBSD 11.1, and I need to remind myself how to unblock an IP from the block list.
Here’s a snippet of what’s in /etc/pf.conf:

table persist

# Don't send rejections. Just drop.
set block-policy drop

# Exempt the loopback interface to prevent services utilizing the
# local loop from being blocked accidentally.
set skip on lo0

# all incoming traffic on external interface is normalized and fragmented
# packets are reassembled.
scrub in on $ext_if all fragment reassemble

# set a default deny policy.
block in log all

# This is a desktop so be permissive in allowing outgoing connections.
pass out quick modulate state

# Enable antispoofing on the external interface
antispoof for $ext_if inet
#antispoof for $ext_if inet6

# block packets that fail a reverse path check. we look up the routing
# table, check to make sure that the outbound is the same as the source
# it came in on. if not, it is probably source address spoofed.
block in from urpf-failed to any

# drop broadcast requests quietly.
block in quick on $ext_if from any to 255.255.255.255

block in log quick on $ext_if inet from  to any

In the pf.conf, the blocked IP table is called “sshguard”. To list all the blocked IPs, run:

# pfctl -t sshguard -T show
   1.0.246.105
   1.9.79.191
   1.52.149.133
   1.53.170.75
   1.164.252.130
   1.212.246.18
   1.217.60.210
   1.235.197.132
...

To unblock an IP, e.g. 1.235.197.132, run:

# pfctl -t sshguard -T delete 1.235.197.132
1/1 addresses deleted.

That’s it. Why is it so hard for me to remember? πŸ˜›

Set the HostName and Computer Name via command line on OS X

Work recently acquired a few MacBook laptops to be used and shared by staff. Though the computing staff is not expected to have immense knowledge about OS X,Β  when things break down we are the first point of contact.

The last time I used a Mac machine extensively was around 2007. Then I switched to Debian and could never look back. Anyway, there must be lot of new things and I’ll try document or post snippets here as I learn new things.

The first one for today is to set the hostname and computer name from a command line.

$ export PC_NAME="macarena"
$ sudo scutil --set ComputerName "$PC_NAME" && \
$ sudo scutil --set HostName "$PC_NAME" && \
$ sudo scutil --set LocalHostName "$PC_NAME"

Reference: OS X – Set the HostName, Computer Name, and Bonjour Name via command line

How to list all installed R-packages

I don’t use R, and I don’t know much about it. However, I maintain R installation on Linux machines at work.

Today, I learned a new trick of listing all installed R-packages. Here it is:

ip = as.data.frame(installed.packages()[,c(1,3:4)])
ip = ip[is.na(ip$Priority),1:2,drop=FALSE]
ip

And here is the sample output:

Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> ip = as.data.frame(installed.packages()[,c(1,3:4)])
> ip = ip[is.na(ip$Priority),1:2,drop=FALSE]
> ip
                  Package   Version
akima               akima    0.5-12
alr3                 alr3     2.0.5
BRugs               BRugs     0.8-6
car                   car     2.1-2
coda                 coda    0.18-1
colorspace     colorspace     1.2-6
DEoptimR         DEoptimR     1.0-5
dichromat       dichromat     2.0-0
digest             digest     0.6.9
distillery     distillery     1.0-2
extRemes         extRemes     2.0-7
fields             fields     8.4-1
...

I don’t have time to explain what each line does. If you’re curious, just check out the references below:

Build Docker Client for ARMv8

The other day, after successfully building Docker-ce 17.06.0-dev for Odroid C2 which has ARMv8 CPU, i couldn’t find Docker client. Maybe it was just me not building the Docker engine correctly.

Anyway, after some more times, I also managed building the Docker client for the Odroid C2. It turned out, like many things, it wasn’t thatΒ  hard after you figured it out. It’s worth to note too that the build instruction on https://github.com/docker/cli is to use Docker container. It didn’t work for me, and I decided to just build the Docker cli locally on the Odroid C2 instead.

First clone the repository:

$ go get github.com/docker/cli
can't load package: package github.com/docker/cli: no Go files in /home/kenno/dev/gowork/src/github.com/docker/cli

So what just happened? Instead of running git clone https://github.com/docker/cli, I use go get command to pull the code from the repo to a path in $GOPATH, since I’m going to build it using go anyway.

Next we can just build it:

$ cd $GOPATH/src/github.com/docker/cli/cmd/docker
go build

When it’s finished, we can run the Docker cli:

Notice that we the Version, “Git commit”, and “Built” fields are set to unknown.

 Version:      unknown-version
 Git commit:   unknown-commit
 Built:        unknown-buildtime

Is there something we can do about? Yes, we can!

$ cd $GOPATH/src/github.com/docker/cli
$ source $GOPATH/src/github.com/docker/cli/scripts/build/.variables
$ go build -o "${TARGET}" --ldflags "${LDFLAGS}" "${SOURCE}"

After the compilation, the Docker cli binary file can be found in ./build directory.

Let’s run it again:

The Version field is still “unknown-version”. This makes sense as we build the code from the master branch.