/root/.blog

Syncing a RPM repo for offline use

For example we want to sync the epel repo for offline use

If you are on CENTOS 7 you can just type:

# yum install epel-release

If not add the EPEL repo this way:

# wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -ivh epel-release-latest-7.noarch.rpm

Install the reposync utility which is included in 'yum-utils':

# yum install yum-utils createrepo

Create an offline copy with the latest files only ('-n' option):

# reposync -n --repoid=epel --download_path=/data

Create repomd (xml-rpm-metadata) repository

# createrepo /data/epel

When you later want to update the repo then just resync it:

# reposync -n --repoid=epel --download_path=/data

Remove older rpm's from the updated repo:

# repomanage -k1 -c -o /data/epel/ |xargs rm

Run createrepo with the --update flag to speed things up

# createrepo --update /var/www/html/repo

Split large file in smaller files

Split

# split -b300M bigfile.zip bigfile.zip.
# ls -al
total 3110156
drwxr-xr-x  2 root root       4096 Sep  6 21:02 .
drwx------ 19 root root       4096 Sep  6 21:01 ..
-rw-r--r--  1 root root 1592381288 Sep  6 21:01 bigfile.zip
-rw-r--r--  1 root root  314572800 Sep  6 21:01 bigfile.zip.aa
-rw-r--r--  1 root root  314572800 Sep  6 21:01 bigfile.zip.ab
-rw-r--r--  1 root root  314572800 Sep  6 21:01 bigfile.zip.ac
-rw-r--r--  1 root root  314572800 Sep  6 21:01 bigfile.zip.ad
-rw-r--r--  1 root root  314572800 Sep  6 21:01 bigfile.zip.ae
-rw-r--r--  1 root root   19517288 Sep  6 21:02 bigfile.zip.af

combine

# cat bigfile.zip.aa bigfile.zip.ab bigfile.zip.ac bigfile.zip.ad \
bigfile.zip.ae bigfile.zip.af > bigfile.zip

Encrypt or Decrypt files

encrypt.sh

#!/bin/bash

infile=$1
outfile=${infile}.enc

if [ -f ${infile} ]; then
    if [ -f ${outfile} ]; then
        echo "target file ${outfile} already exists"
        exit 1
    fi

    printf "Enter encryption password: "
    read pass

    if [ -z ${pass} ]; then
        echo "No password provided, using default: biscuit"
        pass=biscuit
    fi

    cat ${infile} |openssl enc -base64 -e -aes-256-cbc -nosalt -pass pass:${pass} > ${outfile}

fi

decrypt.sh

#!/bin/bash

infile=$1
outfile=`echo ${infile} |sed 's/\.enc//'`

if [ -f ${infile} ]; then
    if [ -f ${outfile} ]; then
        echo "target file ${outfile} already exists"
        exit 1
    fi

    printf "Enter decryption password: "
    read pass

    if [ -z ${pass} ]; then
        echo "No password provided, using default: biscuit"
        pass=biscuit
    fi

    cat ${infile} |openssl enc -base64 -d -aes-256-cbc -nosalt -pass pass:${pass} > ${outfile}

fi
Newer Posts Older Posts