]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* desktop.cc: create /etc/profile
authorDJ Delorie <dj@redhat.com>
Tue, 11 Jul 2000 14:45:18 +0000 (14:45 +0000)
committerDJ Delorie <dj@redhat.com>
Tue, 11 Jul 2000 14:45:18 +0000 (14:45 +0000)
ChangeLog
desktop.cc

index d28bc5d578f251923c60ca43f95357d405c8d47e..c962c714eda496de3ba6fedb50b6ff35adcd998e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2000-07-11  DJ Delorie  <dj@cygnus.com>
+
+       * desktop.cc: create /etc/profile
+
 2000-07-10  DJ Delorie  <dj@cygnus.com>
 
        * Makefile.in: add desktop.o and mklink2.o
index 92c7af3aef975304ac43506fa6a732676b56c924..0d647dbe49985472f657c9deedc27af2398d897d 100644 (file)
@@ -38,6 +38,45 @@ extern "C" {
   void make_link_2 (char *exepath, char *args, char *icon, char *lname);
 };
 
+char *etc_profile[] = {
+  "PATH=/bin:/usr/bin:/usr/local/bin:$PATH",
+  "unset DOSDRIVE",
+  "unset DOSDIR",
+  "unset TMPDIR",
+  "unset TMP",
+  "",
+  "if [ ! -f /etc/group ]; then",
+  "  echo Creating /etc/group",
+  "  mkgroup -l >/etc/group",
+  "fi",
+  "",
+  "USER=`id -un`",
+  "",
+  "# Set up USER's home directory",
+  "if [ -z \"$HOME\" ]; then",
+  "  HOME=/home/$USER",
+  "fi",
+  "",
+  "if [ ! -d $HOME ]; then",
+  "  mkdir -p $HOME",
+  "fi",
+  "",
+  "export HOME USER",
+  "",
+  "for i in /etc/profile.d/*.sh ; do",
+  "  if [ -f $i ]; then",
+  "    . $i",
+  "  fi",
+  "done",
+  "",
+  "export PS1='\033]0;\\w\a",
+  "\033[32m\\u@\\h \033[33m\\w\033[0m",
+  "$ '",
+  "",
+  "cd $HOME",
+  0
+};
+
 #define COMMAND9XARGS "/E:4096 /c "
 #define COMMAND9XEXE  "\\command.com"
 
@@ -147,6 +186,26 @@ make_cygwin_bat ()
   free (usrlocalbin);
 }
 
+static void
+make_etc_profile ()
+{
+  char *fname = concat (root_dir, "/etc/profile", 0);
+
+  /* if the file exists, don't overwrite it */
+  if (_access (fname, 0) == 0)
+    return;
+
+  FILE *p = fopen (fname, "wb");
+  if (!p)
+    return;
+
+  int i;
+  for (i=0; etc_profile[i]; i++)
+    fprintf (p, "%s\n", etc_profile[i]);
+
+  fclose (p);
+}
+
 static void
 save_icon ()
 {
@@ -177,6 +236,7 @@ do_desktop (HINSTANCE h)
   save_icon ();
 
   make_cygwin_bat ();
+  make_etc_profile ();
 
   start_menu ("Cygwin 1.1 Bash Shell", batname);
 
This page took 0.03254 seconds and 5 git commands to generate.