Subject: Re: bug#15168: mkdir alway creates a file instead a direktory if it is run trough a sub sub shell

From: horvan dillus <[email-masked]>
Date: Fri, 23 Aug 2013 21:12:38 +0200

For a better ovvervie  I'll post the  4 scripts I mentioned above:

Script one is written by a presiding file into .bashrc with the preeeded
user ubuntu.

#/!bin/bash
# Bootstrap for first installation and Update.
# This file have to be in loaded in the preseed file.

cat << EOF >> /home/ubuntu/.bashrc

if  [ ! -d /opt/.drubuntu ]; then
echo "We needd yourr password agin to finish the initial setup"
sudo mkdir /opt/.drubuntu;cd /opt/.drubuntu;
wget http://drubuntu.googlecode.com/git/scripts/getit.sh  >/dev/null 2>&1
chmod +x /opt/.drubuntu/getit.sh
./getit.sh
fi

if [ -f /opt/.drubuntu/.bash_aliases } then;
. /opt/.drubuntu/.bash_aliases
fi

EOF

The second script is the script that fetches and runs install.sh

#!/bin/bash
export username=`echo $LOGNAME`
DLURL=http://drubuntu.googlecode.com/git
DIRURL=/opt/.drubuntu
ISCRIPTSURL=/opt/.drubuntu/install
echo "We need your password to finish the initial setup"
sudo chown -Rh "$username" /opt/.drubuntu
echo "prepering initial set up"
mkdir $ISCRIPTSURL
wget -O $DIRURL/setip $DLURL/scripts/setip.sh >  /dev/null 2>&1
wget -O $DIRURL/setwallpaper $DLURL/scripts/setwallpaper.sh >  /dev/null 2>&1

wget -O $DIRURL/install.sh $DLURL/scripts/install/install.sh >   /dev/null 2>&1
wget -O $DIRURL/features $DLURL/features/features.sh > /dev/null 2>&1

wget -O $ISCRIPTSURL/copyfiles $DLURL/scripts/install/copyfiles.sh >
/dev/null 2>&1
wget -O $ISCRIPTSURL/deb-packages
$DLURL/scripts/install/deb-packages.sh > /dev/null 2>&1
wget -O $ISCRIPTSURL/downloadfiles
$DLURL/scripts/install/downloadfiles.sh >  /dev/null 2>&1
wget -O $ISCRIPTSURL/drupal7-core-setup
$DLURL/scripts/install/drupal7-core-setup.sh > /dev/null 2>&1
wget -O $ISCRIPTSURL/drupal8-core-setup
$DLURL/scripts/install/drupal8-core-setup.sh > /dev/null 2>&1
wget -O $ISCRIPTSURL/cleanup $DLURL/scripts/install/cleanup.sh >  /dev/null 2>&1

chmod +x $DIRURL/*; chmod +x $ISCRIPTSURL/*
sudo bash "$DIRURL"/install.sh

the third script runs the script where the mkdir command is present

#!/bin/bash
if [[ $UID -ne 0 ]]; then
   echo    "This script must be run as root, use sudo ./install.sh"
    exit

  fi
echo "We'll now install all missing packages. This will take a while."
  ./install/deb-packages
# > /dev/null to hide the output

#uploadprogress setup

pecl install uploadprogress > /dev/null 2>&1;

#Check for uploadprogress

file="/etc/php5/conf.d/uploadprogress.ini"
if [ -f "$file" ]
then
echo "uploadprogress is already installed"
else
echo "extension=uploadprogress.so" >>/etc/php5/conf.d/uploadprogress.ini
fi

#fetch required files

echo "Files needed will be downloaded now..."
./install/downloadfiles;
echo "Required files will be copied to their locations"
./install/copyfiles;

# grant previleges

chown -Rh "$username":www-data /var/www;
#create symbolic links
ln -s /var/www $HOME/public_html;

#setting up server

hostname drupal.site;
sudo a2enmod rewrite;
sudo a2dissite default;
sudo a2ensite drupal;
sudo service apache2 restart;

echo "Setting up Drush and Drupal"
./install/drupal7-core-setup
read -p "Press [Enter] key if you have noted yourtr password..."
#set privileges
chown -Rh ubuntu:www-data /home/ubuntu/.drush;
chown -Rh ubuntu:www-data /home/ubuntu/.drush/cache
chown -Rh ubuntu:www-data /home/ubuntu/.drush/cache/default
chown -Rh ubuntu:www-data /home/ubuntu/.drush/cache/usage

./install/cleanup
chown -Rh "$username" /opt/.drubuntu
echo ""
echo "To change the MySql Root PWD 'MyRoot' enter"&&
echo ""
echo "mysql_secure_installation"&&
echo ""&&
echo "and follow the advice of the script! Your preseted password for MySql
is MyRoot'"
./features --plymouth > /dev/null
reboot -p

and here is the last script where mkdir is present

#!/bin/bash
DLURL=https://drubuntu.googlecode.com/git
#settiing up drush
drush -y dl drush --destination=/usr/share;
#Download and set up drupal
*
*
*mkdir /var/www/d7*

cd /var/www/d7
drush -y dl drupal;
cd drup*;
cp -r .htaccess .gitignore /var/www/d7;
cp -r * /var/www/d7
cd /var/www/d7
rm -r drup*;
mkdir /var/www/d7/sites/default/files;
chmod 777 /var/www/d7/sites/default/files;
cp -r "/var/www/d7/sites/default/default.settings.php"
"/var/www/d7/sites/default/settings.php";
chmod 777 /var/www/d7/sites/default/settings.php;
wget -O /var/www/d7/setupsite $DLURL/scripts/setupsite.sh >/dev/null 2>&1;
chmod +x /var/www/d7/setupsite;
chown -Rh "$username":www-data /var/www;
chmod 644 /var/www/d7/.htaccess;
chmod 644 "/var/www/d7/sites/default/settings.php";
chmod 644 "/var/www/d7/sites/default/default.settings.php"
sudo bash setupsite
cd /var/www/d7

 The result of the mkdir line I've marked creates a file in var/www that is
called d7 so the rest of the script fails.

There are more scripts of course I hope this will be enough information to
exermain if this is really a bug.

2013/8/23 Bob Proulx <[email-masked]>

> Horvan, Please use reply-all to keep the bug log in the recipient list
> rather than reply to me privately.  That way all of the team can
> participate.  The bug log is that 15168 address in the recipient list.
> Thanks.  I forward this to the bug log.
>
> horvan dillus wrote:
> > This is just one bug related to mkdir The short version of this
> > could be I ran mkdir in a sub sub shell and it creates a file
> > instead a directory as i mentioned in the subject.  this has nothing
> > to do with wget. Sorry for the missunderstanding
>
> Please show us exactly what you did to cause mkdir to create a file
> instead of a directory.  The use of a sub sub shell will not matter to
> mkdir.
>
> Until we see how you did this we will think it is not a bug in mkdir
> but is instead a bug in your script.  But if you show us then all
> doubt is removed.  Please show us.
>
> Bob
>