Project

General

Profile

« Previous | Next » 

Revision 25876144

Added by Andreas Kohlbecker almost 11 years ago

first commits towards fixing #2324

View differences:

src/main/installer/linux/postinst
6 6
set -e
7 7

  
8 8
#
9
#variables
9
# variables
10 10
#
11 11
CDM_HOME="/opt/cdmserver/"
12
CDM_LIBRARY=$CDM_HOME".cdmLibrary"
12
CDM_CONFIG_TEMPLATE="/opt/cdmserver/templates/.cdmLibrary"
13 13
CDM_LOG="/var/log/cdmserver/"
14
bindir="/etc/init.d/"
15
TMP="/usr/bin/"
16 14

  
17
SERVERSCRIPT="cdmserver"
18
SERVERJAR="cdm-server.jar"
19
SERVERCONF="datasources.xml"
20
SERVERREALM="cdm-server-realm.properties"
21
PROPERTIES="cdmserver.properties"
15
INIT_SCRIPT="cdmserver"
16
ETC_CDMSERVER="/etc/cdmserver/"
22 17

  
23
CDM_USER=cdmuser
24
CDM_GROUP=cdmgroup
25
CDM_USER_HOME=/opt/cdmserver/
26
#CDM_USER_HOME=/root/cdmserver/
18
CDM_USER=cdm
19
CDM_GROUP=cdm
20

  
21
CDM_USER_HOME=$CDM_HOME
27 22

  
28 23
#
29
#functions
24
# functions
30 25
#
31 26
userExist(){
32 27
    grep $1 /etc/passwd > /dev/null
......
55 50
    configure)
56 51

  
57 52
    #
58
    # adding the user
59
    # if the user already exist will be deleted
53
    # adding the group
54
    # if the group already exist will be deleted
60 55
    #
61
    if ( userExist $CDM_USER )
56
    if ( groupExist $CDM_GROUP  )
62 57
    then
63
    echo USER ALREADY EXITS!!!!
64
    userdel $CDM_USER
58
      echo "user '$CDM_GROUP' alreday exists"
59
    else
60
      echo "creating group '$CDM_GROUP'"
61
      groupadd $CDM_GROUP
65 62
    fi
66
   
63

  
67 64
    #
68
    # adding the group
69
    # if the group already exist will be deleted
65
    # adding the user
70 66
    #
71
    if ( groupExist $CDM_GROUP  )
67
    if ( userExist $CDM_USER )
72 68
    then
73
        echo GROUP ALREADY EXISTS!!!!
74
        groupdel $CDM_GROUP
69
      echo "user '$CDM_USER' alreday exists"
70
    else
71
      echo "creating user '$CDM_USER'"
72
      useradd -g $CDM_GROUP -d $CDM_USER_HOME $CDM_USER
75 73
    fi
76
    groupadd $CDM_GROUP
77 74

  
78
    useradd -G cdmgroup -d $CDM_USER_HOME $CDM_USER
79 75

  
80
    #installing the script
81
    cp $TMP$SERVERSCRIPT $bindir
82
    chmod 755 $bindir$SERVERSCRIPT
83
    chown $CDM_USER:$CDM_GROUP $bindir$SERVERSCRIPT
84
    update-rc.d $SERVERSCRIPT defaults 98 02
76
    #
77
    # adjusting permissions of init script user and group should be root
78
    #
79
    chmod 755 /etc/init.d/$INIT_SCRIPT
80
    chown root:root /etc/init.d/$INIT_SCRIPT
85 81

  
86
    #creating the directories
87
    if [ ! -d $CDM_HOME ]; then
88
        mkdir -p $CDM_HOME
89
    fi
90
    if [ ! -d $CDM_LIBRARY ]; then
91
        mkdir -p $CDM_LIBRARY
92
    fi
82
    chown -R $CDM_USER:$CDM_GROUP $CDM_HOME
83

  
84
    #
85
    # create log file folder and set owner:group
86
    #
93 87
    if [ ! -d $CDM_LOG ]; then
94 88
        mkdir -p $CDM_LOG
89
        chown -R $CDM_USER:$CDM_GROUP $CDM_LOG
95 90
    fi
96 91

  
97
    #installing the server and the configfile
98
    cp $TMP$SERVERCONF $CDM_LIBRARY
99
    cp $TMP$SERVERREALM $CDM_LIBRARY
100
    cp $TMP$SERVERJAR $CDM_HOME
92
    #
93
    # copy template .cdmLibrary if not yet existing into
94
    # /etc/cdmserver
95
    # AND create symlink
96
    #
97
    if [ ! -d $ETC_CDMSERVER.cdmLibrary ]
98
    then
99
      mkdir -p $ETC_CDMSERVER
100
      cp -r $CDM_CONFIG_TEMPLATE $ETC_CDMSERVER
101
    fi
102
    ln -s $ETC_CDMSERVER.cdmLibrary $CDM_USER_HOME.cdmLibrary
101 103

  
102
    #starting the script
103
    $bindir$SERVERSCRIPT start
104
    # let the cdm server start automatically on boot
105
    update-rc.d $INIT_SCRIPT defaults 98 02
104 106

  
107
    # start the server manually this time
108
    /etc/init.d/$INIT_SCRIPT start
105 109

  
106 110
    ;;
107 111

  

Also available in: Unified diff