Projekt

Obecné

Profil

Stáhnout (2.13 KB) Statistiky
| Větev: | Tag: | Revize:
8baed187 Michal Kliment
#!/bin/bash
################################################################################
# Script for debianization of FreenetIS
# (c) Ondrej Fibich, 2012
#
# Takes one or two arguments (version of package and package - if empty do it all)
# and it generates all FreenetIS packages to directory deb_packages.
#
################################################################################

if [ $# -lt 1 ]; then
echo "Wrong arg count.. Terminating"
exit 1
fi

c1bdc1c4 Michal Kliment
CONFIG="./debianization.conf"

if [ -r $CONFIG ]; then
echo "Loading configuration file"
. $CONFIG
fi

NAMES=(freenetis freenetis-monitoring freenetis-redirection freenetis-dhcp \
freenetis-ssh-keys freenetis-qos)
f5adf00c Ondřej Fibich
DEBIANS=(squeeze wheezy jessie stretch buster)
8baed187 Michal Kliment
VERSION=$1

c2e44ab0 Michal Kliment
if [ $# -eq 2 ] || [ $# -eq 3 ]; then
8baed187 Michal Kliment
NAMES=($2)
fi

c2e44ab0 Michal Kliment
if [ $# -eq 3 ]; then
DEBIANS=($3)
fi

8baed187 Michal Kliment
# functions ####################################################################

function red_echo() {
echo -e "\e[01;31m$1\e[0m"
}

function green_echo() {
echo -e "\e[01;32m$1\e[0m"
}

# create dirs ##################################################################
rm -rf deb_packages
mkdir deb_packages

# call all debianization utils #################################################

c1bdc1c4 Michal Kliment
root_dir=`pwd`

8baed187 Michal Kliment
for name in ${NAMES[*]}
do
c1bdc1c4 Michal Kliment
name_mod=`echo $name | sed 's/-/_/g'`
c2e44ab0 Michal Kliment
for debian in ${DEBIANS[*]}
do
c1bdc1c4 Michal Kliment
# get dir from config or default
conf_var_name="${name_mod}_debianization"
eval_str="echo \${${conf_var_name}}"
deb_dir_sh=`eval "$eval_str"`
if [[ -z "$deb_dir_sh" ]]; then
deb_dir_sh="./$name/"
fi

deb_sh="$deb_dir_sh/debianization.sh"
8baed187 Michal Kliment
c1bdc1c4 Michal Kliment
# run debianization
if [ -f "$deb_sh" ]; then
cd "$deb_dir_sh"
./debianization.sh "$VERSION" "$debian"
2a205303 Michal Kliment
c1bdc1c4 Michal Kliment
if [ $? -eq 0 ]; then
c2e44ab0 Michal Kliment
green_echo ">>>> [$name+$debian] debianized"
c1bdc1c4 Michal Kliment
# move builded packages
if [ -d "deb_packages" ]; then
mkdir -p "$root_dir/deb_packages"
mv -f deb_packages/* "$root_dir/deb_packages"
fi
else
c2e44ab0 Michal Kliment
red_echo ">>>> [$name+$debian] an error occured during debianization"
c1bdc1c4 Michal Kliment
fi
2a205303 Michal Kliment
c1bdc1c4 Michal Kliment
cd "$root_dir"
else
c2e44ab0 Michal Kliment
red_echo ">>>> [$name+$debian] not debianized (debianization utility is missing)"
c1bdc1c4 Michal Kliment
fi
done
c2e44ab0 Michal Kliment
done