/usr/share/xcrysden/scripts/xcConfigure_updateProfile.sh is in xcrysden-data 1.5.60-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | # ------------------------------------------------------------------------
# FUNCTIONS
# ------------------------------------------------------------------------
ScratchDir () {
$ECHO_n " Please specify XCRYSDEN_SCRATCH directory (default: $HOME/xcrys_tmp): "
read ans
if [ ! -d ${ans:=$HOME/xcrys_tmp} ]; then
mkdir ${ans:=$HOME/xcrys_tmp}
fi
if [ $? -gt 0 ]; then
echo "ERROR: can't create directory $ans"
ScratchDir
fi
xc_scratch=${ans:=$HOME/xcrys_tmp}
}
GetProfile () {
$ECHO_n " Please specify your profile (default $1):"
read ans
if [ "$ans" = "" ]; then
ans=$1
if [ ! -w "$ans" ]; then
echo " $ans is not writable; please specify an alternative profile"
GetProfile $profile
fi
fi
if [ \( ! -f "$ans" \) -o \( ! -w "$ans" \) ]; then
echo " profile $ans does not exists or is not writable; Try again !!!"
GetProfile $profile
fi
profile=$ans
}
PrintTwoProfileBlocks() {
echo "For sh-based shells:
"
cat $tempdir/xcInstall-sh.$$
echo "Foc Csh-based shells:
"
$tempdir/xcInstall-csh.$$
}
# ------------------------------------------------------------------------
# MAIN
# ------------------------------------------------------------------------
ver=`cat $XCRYSDEN_TOPDIR/version`
$CLEAR
echo "
========================================================================
* * * * XCRYSDEN's Configuration/Setup Utility * * * *
------------------------------------------------------------------------
XCRYSDEN version: $ver
PLEASE FOLLOW INSTRUCTIONS DURING THE CONFIGURATION PROCEDURE !!!
=========================================================================
Press <Enter> to continue ..." | $MORE
read ans
$CLEAR
#
# get the scratch directory
#
xc_scratch=$XCRYSDEN_SCRATCH
if [ "$XCRYSDEN_SCRATCH" = "" ]; then
ScratchDir
fi
XCRYSDEN_SCRATCH=$xc_scratch
#
# get the user-shell
#
if test -z $SHELL; then
echo "
WARNING: the SHELL variable does not exists. This is weird !!!
"
fi
user_shell=`echo $SHELL | awk '{n=split($0,shell,"/"); print shell[n]}'`
# for Csh-based shells
echo "
#------------------------------------------------------------------------
# this is for XCRYSDEN $VER; added by XCRYSDEN installation on
# $date
#------------------------------------------------------------------------
setenv XCRYSDEN_TOPDIR $XCRYSDEN_TOPDIR
setenv XCRYSDEN_SCRATCH $xc_scratch
set path = (\$XCRYSDEN_TOPDIR \$path \$XCRYSDEN_TOPDIR/scripts \$XCRYSDEN_TOPDIR/util)
" > $tempdir/xcInstall-csh.$$
# for sh-based shells
echo "
#------------------------------------------------------------------------
# this is for XCRYSDEN $ver; added by XCRYSDEN installation on
# $date
#------------------------------------------------------------------------
XCRYSDEN_TOPDIR=$XCRYSDEN_TOPDIR
XCRYSDEN_SCRATCH=$xc_scratch
export XCRYSDEN_TOPDIR XCRYSDEN_SCRATCH
PATH=\"\$XCRYSDEN_TOPDIR:\$PATH:\$XCRYSDEN_TOPDIR/scripts:\$XCRYSDEN_TOPDIR/util\"
" > $tempdir/xcInstall-sh.$$
#
# get the profile and corresponding install_file
#
if test \( x"$user_shell" = x"csh" \) -o \( x"$user_shell" = x"tcsh" \) ; then
# Csh and Tcsh
profile=$HOME/.cshrc
install_file=$tempdir/xcInstall-csh.$$
elif test x"$user_shell" = x"bash" ; then
# Bash
profile=$HOME/.bashrc
install_file=$tempdir/xcInstall-sh.$$
elif test -n $user_shell ; then
# assuming some Sh-based shell
profile=$HOME/.profile
install_file=$tempdir/xcInstall-sh.$$
else
profile=""
install_file=/dev/null
echo " You will have to edit your profile (\$HOME/.bashrc or
\$HOME/.profile or \$HOME/.csh) manually and add the
following:
"
PrintTwoProfileBlocks
fi
#
# write (if possible) to profile
#
grep_result=
if test -n $profile ; then
if [ -f $profile ]; then
grep_result=`grep XCRYSDEN_TOPDIR $profile`
fi
if [ \( "$xcv" = "" \) -o \( "$grep_result" = "" \) ]; then
# update profile
if [ -f $profile ]; then
if [ ! -w $profile ]; then
echo "
ERROR: cannot write to $profile because it is write-protected !!!
You will have to edit your profile manually and add the
following:
"
cat $install_file
fi
cp $profile $profile.orig
else
touch $profile.orig
fi
$ECHO_n "
Updating profile file $profile ... "
cat $profile.orig $install_file > $profile
if [ $? -eq 0 ]; then
echo OK
else
echo FAILED
fi
echo "
The following record was inserted into $profile:
" | cat - $install_file
else
echo "
========================================================================
WARNING ***
WARNING *** XCRYSDEN_TOPDIR enviromental variable is already defined.
WARNING ***
You will have to edit your profile (i.e. \$HOME/.chsrc or
\$HOME/.bashrc or \$HOME/.profile) manually and make the
XCRYSDEN section as shown below:
" | cat - $install_file | $MORE
echo "
Press <Enter> to continue ..."
read ans
$CLEAR
fi
fi
|