3 # This file is part of the Cygwin DLL.
5 # Directory where the config files are stored
11 service_name
=cygserver
15 if [ "${auto_answer}" = "yes" ]
17 echo "$1 (yes/no) yes"
19 elif [ "${auto_answer}" = "no" ]
26 while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ]
28 echo -n "$1 (yes/no) "
31 if [ "X${answer}" = "Xyes" ]
71 echo "usage: ${progname} [OPTION]..."
73 echo "This script creates an Cygserver service configuration."
76 echo " --debug -d Enable shell's debug output."
77 echo " --yes -y Answer all questions with \"yes\" automatically."
78 echo " --no -n Answer all questions with \"no\" automatically."
79 echo " --name -N <name> cygserver windows service name."
87 # Check if running on NT
89 _nt
=`expr "${_sys}" : "CYGWIN_NT"`
91 # Check for running cygserver processes first.
92 if ps
-ef |
grep -v grep |
grep -q ${service_name}
95 echo "There is a cygserver (${service_name}) already running. Nothing to do, apparently."
100 # Check for ${SYSCONFDIR} directory
101 if [ -e "${SYSCONFDIR}" -a ! -d "${SYSCONFDIR}" ]
104 echo "${SYSCONFDIR} is existant but not a directory."
105 echo "Cannot create global configuration file."
110 # Create it if necessary
111 if [ ! -e "${SYSCONFDIR}" ]
113 mkdir
"${SYSCONFDIR}"
114 if [ ! -e "${SYSCONFDIR}" ]
117 echo "Creating ${SYSCONFDIR} directory failed"
123 # Create /var/log if not already existing
124 if [ -f ${LOCALSTATEDIR}/log
]
126 echo "Creating ${LOCALSTATEDIR}/log failed!"
128 if [ ! -d ${LOCALSTATEDIR}/log
]
130 mkdir
-p ${LOCALSTATEDIR}/log
134 # Check if cygserver.conf exists. If yes, ask for overwriting
135 if [ -f "${SYSCONFDIR}/cygserver.conf" ]
137 if request
"Overwrite existing ${SYSCONFDIR}/cygserver.conf file?"
139 rm -f "${SYSCONFDIR}/cygserver.conf"
140 if [ -f "${SYSCONFDIR}/cygserver.conf" ]
143 echo "Can't overwrite. ${SYSCONFDIR}/cygserver.conf is write protected."
150 # Create default cygserver.conf from skeleton files in /etc/defaults/etc
151 if [ ! -f "${SYSCONFDIR}/cygserver.conf" ]
153 echo "Generating ${SYSCONFDIR}/cygserver.conf file"
154 cp "${SYSCONFDIR}/defaults/etc/cygserver.conf" "${SYSCONFDIR}/cygserver.conf"
155 if [ ! -f "${SYSCONFDIR}/cygserver.conf" ]
158 echo "Couldn't create ${SYSCONFDIR}/cygserver.conf."
159 echo "Perhaps there's no default file in ${SYSCONFDIR}/defaults/etc?"
160 echo "Reinstalling Cygwin might help."
164 chmod 664 "${SYSCONFDIR}/cygserver.conf"
165 chown
18.544 "${SYSCONFDIR}/cygserver.conf"
168 # On NT ask if cygserver should be installed as service
171 # But only if it is not already installed
172 if ! cygrunsrv
-Q ${service_name} > /dev
/null
2>&1
176 echo "Warning: The following function requires administrator privileges!"
178 echo "Do you want to install cygserver as service?"
179 if request
"(Say \"no\" if it's already installed as service)"
181 if ! cygrunsrv
-I ${service_name} -d "CYGWIN cygserver" -p /usr
/sbin
/cygserver
184 echo "Installation of cygserver as service failed. Please check the"
185 echo "error messages you got. They might give a clue why it failed."
187 echo "A good start is either you don't have administrator privileges"
188 echo "or a missing cygrunsrv binary. Please check for both."
193 echo "The service has been installed under LocalSystem account."
194 echo "To start it, call \`net start ${service_name}' or \`cygrunsrv -S ${service_name}'."
196 touch "${LOCALSTATEDIR}/log/cygserver.log"
197 chown
18.544 "${LOCALSTATEDIR}/log/cygserver.log"
202 echo "Further configuration options are available by editing the configuration"
203 echo "file ${SYSCONFDIR}/cygserver.conf. Please read the inline information in that"
204 echo "file carefully. The best option for the start is to just leave it alone."
206 echo "Basic Cygserver configuration finished. Have fun!"