source: bin/qtp-config @ 3

Revision 3, 5.3 KB checked in by jake, 6 years ago (diff)

Brought up to date for new packages

  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# Copyright (C) 2006-2008 Eric Shubert
4# Eric 'shubes' <plug@shubes.net>
5#
6# Set configuration variables for the qtp package
7#
8###################################################################
9# change log
10# 01/07/08 shubes - added UNIONROOT for qtp-newmodel
11#                 - renamed a1 <-> a2 so they're in order
12# 06/27/07 Jake   - Moved a2_backup_variables to head of script to make
13#                 - it easier for user to set these variables.
14#                 - Added more comments for clarity
15# 03/06/07 shubes - added x01_compare_versions function
16# 01/13/07 shubes - added RPMBUILD_OPT_DIR variable
17# 01/04/07 shubes - added QMT_DEV variable
18# 01/03/07 shubes - added RPMBUILD_OPTIONS variable
19###################################################################
20
21#####################################################################
22## set variables for qtp-backup processing
23#
24a1_backup_variables(){
25
26# backupdest is the Backup Destination on your HD (don't include trailing /)
27# If the dir does not exist, it will be created for you.
28# ex:  backupdest=/backuphd/toasterbackup
29export backupdest=/backup/qmailbkup
30
31# FTP Information and Destination
32# This will upload the files backed up via FTP using Curl ( y or n )
33export useftp=n
34
35# Syntax for ftpserver:  ftp://user:pass@ftp.server.com/folder  (WITHOUT Trailing /)
36export ftpserver=ftp://
37
38# E-Mail Information and Destination
39# This will Send you an e-mail after the Cron Job Runs each time. ( y or n )
40export emailinfo=y
41
42# Syntax for email:  your@emailaddress.com
43export email=postmaster
44
45# Remove previous backup file before creating a new one? ( y or n )
46export removeprevious=n
47}
48
49#####################################################################
50## set variables for qtp-newmodel processing
51#
52a2_newmodel_variables(){
53
54# this is used by qtp-newmodel and qtp-ami-up2date
55#export QMT_WEB=http://www.qmailtoaster.com
56export QMT_WEB=http://www.qmailtoaster.org
57export QMT_DEV=http://devel.qmailtoaster.com
58
59# these are used by qtp-newmodel and subscripts
60export UPGRADE_DIR=/usr/src/qtp-upgrade
61export SANDBOX=/mnt/qtp-sandbox
62export UNIONROOT=/opt/qtp-unionroot
63
64# you may specify any global options for rpmbuild here (used by qtp-build-rpms)
65#export RPMBUILD_OPTIONS="-v"
66#export RPMBUILD_OPTIONS="--quiet"
67export RPMBUILD_OPTIONS=""
68
69# you may specify any package specific options for rpmbuild
70# by creating a file named 'package' (e.g. qmailadmin-toaster)
71# in the RPMBUILD_OPT_DIR directory which contains the parameters
72# you would like to use, e.g. "--define 'spambox 1'"
73export RPMBUILD_OPT_DIR=/opt/qmailtoaster-plus/etc/rpmbuild
74}
75
76
77###################################################################
78## compare versions, function used by qtp-newmodel, qtp-ami-up2date
79#
80x01_compare_versions(){
81
82installed_version=${installed_pkgver#${QMT_PKGNAME}-}
83
84if [ "$QMT_PKGNAME" == "zlib" ]; then
85  installed_qmtver=${installed_version%-[^-]*}
86  QMT_QMTVER=${QMT_VERSION%-[^-]*}
87else
88  installed_qmtver=${installed_version#[^-]*-}
89  QMT_QMTVER=${QMT_VERSION#[^-]*-}
90fi
91
92inst_v1=${installed_qmtver%%.[.0-9]*}
93inst_temp=${installed_qmtver#${inst_v1}}
94inst_temp=${inst_temp#.}
95inst_v2=${inst_temp%%.[.0-9]*}
96inst_temp=${inst_temp#${inst_v2}}
97inst_temp=${inst_temp#.}
98inst_v3=${inst_temp%%.[.0-9]*}
99: ${inst_v3:=0}
100
101updt_v1=${QMT_QMTVER%%.[.0-9]*}
102updt_temp=${QMT_QMTVER#${updt_v1}}
103updt_temp=${updt_temp#.}
104updt_v2=${updt_temp%%.[.0-9]*}
105updt_temp=${updt_temp#${updt_v2}}
106updt_temp=${updt_temp#.}
107updt_v3=${updt_temp%%.[.0-9]*}
108: ${updt_v3:=0}
109
110if [ $((updt_v1)) -gt $((inst_v1)) ] \
111      || ( [ $((updt_v1)) -eq $((inst_v1)) ] \
112           && [ $((updt_v2)) -gt $((inst_v2)) ] ) \
113      || ( [ $((updt_v1)) -eq $((inst_v1)) ] \
114           && [ $((updt_v2)) -eq $((inst_v2)) ] \
115           && [ $((updt_v3)) -gt $((inst_v3)) ] ); then
116  return 0
117else
118  return 1
119fi
120
121}
122
123###################################################################
124## determine which union filesystem type to use based on kernel version
125#
126x02_kernel_unionfs_switch() {
127
128kernelrelease=$(uname -r)
129kernelver=${kernelrelease%-[^-]*}
130kernelmajorver=${kernelver%.[^.]*}
131declare -i kernelminorver=${kernelver##[^.]*.}
132
133if [ "$kernelmajorver" == "2.6" ]; then
134  if [ "$kernelminorver" -ge "18" ]; then
135    echo "aufs"
136  elif [ "$kernelminorver" -ge "16" ]; then
137    echo "unionfs12"
138  elif [ "$kernelminorver" -ge "11" ]; then
139    echo "unionfs"
140  elif [ "$kernelminorver" -ge "9" ]; then
141    echo "unionfs115"
142  fi
143fi
144
145unset kernelrelease
146unset kernelver
147unset kernelmajorver
148unset kernelminorver
149}
150
151#####################################################################
152## main execution begins here
153#
154
155myname=qtp-config
156myver=v0.2.4
157
158if [ "`basename $0`" == "$myname" ]; then
159  retexit=exit
160else
161  retexit=return
162fi
163
164unset silent
165if [ ! -z "$1" ]; then
166  case $1 in
167    -s )
168      silent=$1
169      ;;
170    * )
171      echo "$myname usage: $myname [-s]"
172      $retexit 8
173      ;;
174  esac
175else
176  echo "$myname $myver"
177fi
178
179a1_backup_variables
180
181a2_newmodel_variables
182
183if [ ! $silent ]; then
184  echo "QMT_WEB=$QMT_WEB"
185  echo "QMT_DEV=$QMT_DEV"
186  echo "SANDBOX=$SANDBOX"
187  echo "UNIONROOT=$UNIONROOT"
188  echo "UPGRADE_DIR=$UPGRADE_DIR"
189  echo "RPMBUILD_OPTIONS=$RPMBUILD_OPTIONS"
190  echo "backupdest=$backupdest"
191  echo "useftp=$useftp"
192  echo "ftpserver=$ftpserver"
193  echo "emailinfo=$emailinfo"
194  echo "email=$email"
195  echo "removeprevious=$removeprevious"
196fi
197
198$retexit 0
Note: See TracBrowser for help on using the repository browser.