~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to packages/solaris/CSW/boincclient/preinstall

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
PATH=/bin:/usr/bin:/usr/ucb/bin:/opt/csw/bin
 
4
export PATH
 
5
 
 
6
if [ -x $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf ] ; then 
 
7
  . $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf 
 
8
fi 
 
9
if [ -x $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf ] ; then 
 
10
  . $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf 
 
11
fi 
 
12
 
 
13
BOINCUSER=boinc
 
14
BOINCGROUP="`( groups ${BOINCUSER} 2>/dev/null || echo boinc ) | gawk '{print $1}'`"
 
15
 
 
16
MAJOR=`uname -r | gawk -F. '{print $1}'`
 
17
MINOR=`uname -r | gawk -F. '{print $2}'`
 
18
# find our run directory
 
19
if [ $MAJOR -gt 5 -o \( $MAJOR -eq 5 -a $MINOR -gt 9 \) ] ; then
 
20
  BOINCDIR=$PKG_INSTALL_ROOT/var/lib/boinc
 
21
  if [ -d $PKG_INSTALL_ROOT/var/opt/csw/boinc -a ! -d $PKG_INSTALL_ROOT/var/lib/boinc ] ; then
 
22
    mv -f $PKG_INSTALL_ROOT/var/opt/csw/boinc $PKG_INSTALL_ROOT/var/lib/boinc
 
23
  fi
 
24
else
 
25
  BOINCDIR=$PKG_INSTALL_ROOT/var/opt/csw/boinc
 
26
fi
 
27
 
 
28
# find out if the group $BOINCGROUP exists
 
29
GROUPENT=`getent group $BOINCGROUP`
 
30
 
 
31
# if we need to create the boinc group, find the first unused group number
 
32
# 2316 or highter
 
33
if [ -z "${GROUPENT}" ] ; then 
 
34
  getent group | gawk -F: '{print $3}' > /tmp/$$.grp
 
35
  try=2316
 
36
  while [ ! -z "`grep \^$try /tmp/$$.grp`" ] ; do
 
37
    try=`expr $try + 1`
 
38
  done
 
39
  GROUPNUM=${try}
 
40
  GROUPENT="${BOINCGROUP}::${try}:"
 
41
  cp $PKG_INSTALL_ROOT/etc/group $PKG_INSTALL_ROOT/etc/group.boinc_install.bak
 
42
  echo ${GROUPENT} >> $PKG_INSTALL_ROOT/etc/group
 
43
  /bin/rm /tmp/$$.grp
 
44
else 
 
45
  GROUPNUM=`echo $GROUPENT | gawk -F: '{print $3}'`
 
46
fi
 
47
 
 
48
# Now find out if the user ${BOINCUSER} exists.
 
49
USERENT=`getent passwd $BOINCUSER`
 
50
 
 
51
# if we need to create the boinc group, find the first unused user number
 
52
# ${BOINCGROUP} or highter
 
53
if [ -z "${USERENT}" ] ; then 
 
54
  getent passwd | gawk -F: '{print $3}' >/tmp/$$.user
 
55
  try="${GROUPNUM}"
 
56
  while [ ! -z "`grep \^$try /tmp/$$.user`" ] ; do
 
57
    try=`expr $try + 1`
 
58
  done
 
59
  USERENT="${BOINCUSER}:x:${try}:${GROUPNUM}:BOINC client user:${BOINCDIR}:/bin/ksh" 
 
60
  cp $PKG_INSTALL_ROOT/etc/passwd $PKG_INSTALL_ROOT/etc/passwd.boinc_install.bak
 
61
  echo $USERENT >> $PKG_INSTALL_ROOT/etc/passwd
 
62
  /bin/rm /tmp/$$.user
 
63
fi
 
64
 
 
65
# Does our user entry point to the correct directory?
 
66
if [ -z "`echo $USERENT | grep $BOINCDIR`" ] ; then
 
67
  # No.  We need to correct it.
 
68
  USERENT=`echo $USERENT | gawk -F: '{print $1":"$2":"$3":"$4":"$5":'$BOINCDIR':"$7}'`
 
69
  grep -v \^${BOINCUSER}: $PKG_INSTALL_ROOT/etc/passwd > /tmp/passwd.$$
 
70
  echo "$USERENT" >> /tmp/passwd.$$
 
71
  if [ ! -f $PKG_INSTALL_ROOT/etc/passwd.boinc_install.bak ] ; then 
 
72
    cp $PKG_INSTALL_ROOT/etc/passwd $PKG_INSTALL_ROOT/etc/passwd.boinc_install.bak
 
73
  fi
 
74
  mv -f /tmp/passwd.$$ $PKG_INSTALL_ROOT/etc/passwd
 
75
fi
 
76
 
 
77
# check for our shadow entry
 
78
shadent="`grep \^$BOINCUSER: $PKG_INSTALL_ROOT/etc/shadow`"
 
79
if [ -z "$shadent" ] ; then
 
80
  shadent="${BOINCUSER}:NP:16384::::::"
 
81
  cp $PKG_INSTALL_ROOT/etc/shadow $PKG_INSTALL_ROOT/etc/shadow.boinc_install.bak
 
82
  chmod 0400 $PKG_INSTALL_ROOT/etc/shadow.boinc_install.bak
 
83
  echo $shadent >> $PKG_INSTALL_ROOT/etc/shadow
 
84
fi
 
85
 
 
86
# Create the run directory and set permissions properly.
 
87
if [ ! -d $BOINCDIR ] ; then
 
88
  mkdir -p $BOINCDIR
 
89
fi
 
90
chown -R $BOINCUSER:$BOINCGROUP $BOINCDIR
 
91