~swag/armagetronad/0.2.9-sty+ct+ap-fork

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
#
# starts @progtitle@ from the installation directory

# set -x

INSTALL=@rpmroot@@prefix@/games/@progname@

#find old configuration
if test @enable_etc@ = yes ; then
    CONFIG=@rpmroot@/etc/@prognamebase@
else
    CONFIG=$INSTALL/config
fi

if test -r $INSTALL/.config.orig ; then
    CONFIG_ORIG=$INSTALL/.config.orig
    CONFIG_OLD=$INSTALL/config
else
    if test -r @rpmroot@/etc/@prognamebase@/.orig ; then
	CONFIG_ORIG=@rpmroot@/etc/@prognamebase@/.orig
	CONFIG_OLD=@rpmroot@/etc/@prognamebase@
    else
	if test -r $INSTALL/config/.orig ; then
	    CONFIG_ORIG=$INSTALL/config/.orig
	CONFIG_OLD=$INSTALL/config
	fi
    fi
fi

NEW_CONFIG_ORIG=$CONFIG/.orig
CONFIG_USER=$CONFIG/.user
CONFIG_NEW=$CONFIG/.new

BIN=@rpmroot@@prefix@/bin

FORCE=n

STARTSERVER=NO
STARTMASTER=NO

UPDATE=no

if test -r $INSTALL/bin/@progname@ ; then
    if test ! "$1" = "-f" -a ! "$1" = "-u" ; then
	echo "Installation aborted; detected previous installation."
	echo "Use \"install -f\"/\"make install_force\" to force installation ( previous version will get overwritten )"
	echo "or \"install -u\"/\"make update\" ( your configuration files will be kept; requires diff3 )."
	exit 1
    else
	if test -r ./rc.d/@prognamebase@  ; then
	    FORCE=y
	    $INSTALL/rc.d/@prognamebase@ status        && STARTSERVER=yes
	    $INSTALL/rc.d/@prognamebase@-master status && STARTMASTER=yes
	fi

	install -m 755 -d $CONFIG

	# make backup of old configuration
	rm -rf $CONFIG_USER.old
	test -d $CONFIG_USER && mv $CONFIG_USER $CONFIG_USER.old
	mkdir $CONFIG_USER
	test -r $CONFIG_OLD/settings.cfg && cp $CONFIG_OLD/* $CONFIG_USER
	rm -f $CONFIG_USER/*~

	if test "$1" = "-u"; then
	    UPDATE=yes
	fi
    fi
fi


echo
echo "Making directories..."
install -m 755 -d $BIN || { echo "Installation failed. Bin folder does not exist and cannot be created."; exit 1; }

install -m 755 -d $INSTALL/log || { echo "Installation failed. Install folder does not exist and cannot be created."; exit 1; }

install -m 755 -d $CONFIG || { echo "Installation failed. Configuration folder does not exist and cannot be created."; exit 1; }


if test $STARTSERVER = yes ; then
    ./rc.d/@prognamebase@ stop
fi

if test $STARTMASTER = yes ; then
    ./rc.d/@prognamebase@-master stop
fi

if test "@rpmroot@" = "dddd" ; then
    if ! install -m 755 -d @rpmroot@ ; then
	echo "Installation failed. RPM root folder does not exist and cannot be created."
	exit 1
    fi
fi

echo "Copying data..."
rm -rf $INSTALL/doc
rm -rf $INSTALL/bin/*
cp -R * $INSTALL || { echo "Installation failed. Either the installation target is write protected or your disk is full."; exit 1; }

rm -rf $INSTALL/install
rm -rf $INSTALL/bin/starter
rm -rf $INSTALL/bin/stat

echo "Installing scripts..."
install -m 755 bin/starter $BIN/@progname@ || { echo "Installation failed. Could not install launcher. You may have insufficient rights to $BIN."; exit 1 ;}

install -m 755 bin/stat $BIN/@prognamebase@-stat || { echo "Installation failed. Could not install server browser. . You may have insufficient rights to $BIN."; exit 1; }

#copy new configuration
if test @enable_etc@ = yes ; then
    test -d $CONFIG || mkdir $CONFIG
    cp $INSTALL/config/* $CONFIG
fi

rm -rf $CONFIG_NEW
mkdir $CONFIG_NEW
cp $CONFIG/* $CONFIG_NEW

if test "$UPDATE" = "yes" && test -d $CONFIG_ORIG; then
    echo "Integrating user changes..." #"from $CONFIG_USER to $CONFIG_ORIG and $CONFIG..."
	test -r $CONFIG_USER || mkdir $CONFIG_USER
	test -r $CONFIG_ORIG || mkdir $CONFIG_ORIG
    
    chmod 755 $CONFIG_ORIG

    PWD_OLD=$( pwd )
    cd $CONFIG_USER
    for f in *; do
	if test ! "$f" = "*" ; then
	    if test ! -r $CONFIG/$f || test ! -r $CONFIG_ORIG/$f ; then
			echo " " Copying $f...
			cp $f $CONFIG
	    else
			echo " " Merging $f...
			diff3 -m -L "Your version follows:" $f -L "Original version follows:" $CONFIG_ORIG/$f -L "New version above." $CONFIG_NEW/$f > $CONFIG/$f || { echo -e "\nWarning: conflicts during configuration merge of config/$f.\nYou should check it manually.\n" ; WARN=ON; }
	    fi
	fi
    done
    cd $PWD_OLD
fi

rm -rf $CONFIG_ORIG
rm -rf $NEW_CONFIG_ORIG
mv $CONFIG_NEW $NEW_CONFIG_ORIG
chmod 755 $NEW_CONFIG_ORIG
chmod 400 $NEW_CONFIG_ORIG/*
echo -e "Don't change anything in this directory; it will be needed exactly as it is now\nwhen you upgrate to a new version." >> $NEW_CONFIG_ORIG/README

#delete obsolete configuration
if test @enable_etc@ = yes ; then
    rm -rf $INSTALL/config*
else
    rm -rf @rpmroot@/etc/@prognamebase@
fi

if test $STARTMASTER = yes ; then
    ./rc.d/@prognamebase@-master start
fi

if test $STARTSERVER = yes ; then
    ./rc.d/@prognamebase@ start
fi

echo -e "Installation complete! Just type @progname@ to start.\n"
if test "$WARN" = "ON"; then
    echo -e "Check the above output for warnigs first!\n"
fi