3 # cygserver-config, Copyright 2003 Red Hat Inc.
5 # This file is part of the Cygwin DLL.
7 # Directory where the config files are stored
16 if [ "${auto_answer}" = "yes" ]
18 echo "$1 (yes/no) yes"
20 elif [ "${auto_answer}" = "no" ]
27 while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ]
29 echo -n "$1 (yes/no) "
32 if [ "X${answer}" = "Xyes" ]
67 echo "usage: ${progname} [OPTION]..."
69 echo "This script creates an Cygserver service configuration."
72 echo " --debug -d Enable shell's debug output."
73 echo " --yes -y Answer all questions with \"yes\" automatically."
74 echo " --no -n Answer all questions with \"no\" automatically."
82 # Check if running on NT
84 _nt=`expr "${_sys}" : "CYGWIN_NT"`
86 # Check for running cygserver processes first.
87 if ps -ef | grep -v grep | grep -q cygserver
90 echo "There is a cygserver already running. Nothing to do, apparently."
95 # Check for ${SYSCONFDIR} directory
96 if [ -e "${SYSCONFDIR}" -a ! -d "${SYSCONFDIR}" ]
99 echo "${SYSCONFDIR} is existant but not a directory."
100 echo "Cannot create global configuration file."
105 # Create it if necessary
106 if [ ! -e "${SYSCONFDIR}" ]
108 mkdir "${SYSCONFDIR}"
109 if [ ! -e "${SYSCONFDIR}" ]
112 echo "Creating ${SYSCONFDIR} directory failed"
118 # Create /var/log if not already existing
119 if [ -f ${LOCALSTATEDIR}/log ]
121 echo "Creating ${LOCALSTATEDIR}/log failed!"
123 if [ ! -d ${LOCALSTATEDIR}/log ]
125 mkdir -p ${LOCALSTATEDIR}/log
129 # Check if cygserver.conf exists. If yes, ask for overwriting
130 if [ -f "${SYSCONFDIR}/cygserver.conf" ]
132 if request "Overwrite existing ${SYSCONFDIR}/cygserver.conf file?"
134 rm -f "${SYSCONFDIR}/cygserver.conf"
135 if [ -f "${SYSCONFDIR}/cygserver.conf" ]
138 echo "Can't overwrite. ${SYSCONFDIR}/cygserver.conf is write protected."
145 # Create default cygserver.conf from skeleton files in /etc/defaults/etc
146 if [ ! -f "${SYSCONFDIR}/cygserver.conf" ]
148 echo "Generating ${SYSCONFDIR}/cygserver.conf file"
149 cp "${SYSCONFDIR}/defaults/etc/cygserver.conf" "${SYSCONFDIR}/cygserver.conf"
150 if [ ! -f "${SYSCONFDIR}/cygserver.conf" ]
153 echo "Couldn't create ${SYSCONFDIR}/cygserver.conf."
154 echo "Perhaps there's no default file in ${SYSCONFDIR}/defaults/etc?"
155 echo "Reinstalling Cygwin might help."
159 chmod 664 "${SYSCONFDIR}/cygserver.conf"
160 chown system.544 "${SYSCONFDIR}/cygserver.conf"
163 # On NT ask if cygserver should be installed as service
166 # But only if it is not already installed
167 if ! cygrunsrv -Q cygserver > /dev/null 2>&1
171 echo "Warning: The following function requires administrator privileges!"
173 echo "Do you want to install cygserver as service?"
174 if request "(Say \"no\" if it's already installed as service)"
176 if ! cygrunsrv -I cygserver -d "CYGWIN cygserver" -p /usr/sbin/cygserver
179 echo "Installation of cygserver as service failed. Please check the"
180 echo "error messages you got. They might give a clue why it failed."
182 echo "A good start is either you don't have administrator privileges"
183 echo "or a missing cygrunsrv binary. Please check for both."
188 echo "The service has been installed under LocalSystem account."
189 echo "To start it, call \`net start cygserver' or \`cygrunsrv -S cygserver'."
191 touch "${LOCALSTATEDIR}/log/cygserver.log"
192 chown system.544 "${LOCALSTATEDIR}/log/cygserver.log"
197 echo "Further configuration options are available by editing the configuration"
198 echo "file ${SYSCONFDIR}/cygserver.conf. Please read the inline information in that"
199 echo "file carefully. The best option for the start is to just leave it alone."
201 echo "Please keep in mind, that a client application which wants to use"
202 echo "the services provided by cygserver *must* have the environment variable"
203 echo "CYGWIN set so that it contains the word \"server\". So, if you don't"
204 echo "need any other special CYGWIN setting, just set it to \"server\"".
206 echo "It is advisable to add this setting to the Windows system environment."
208 echo "Basic Cygserver configuration finished. Have fun!"