Hey!
Thank you very much for answering my question.
As far as I know, vagrant executes the script as root, here in this link
<https://www.google.com/url?q=https%3A%2F%2Fwww.vagrantup.com%2Fdocs%2Fprovisioning%2Fshell.html&sa=D&sntz=1&usg=AFQjCNE5Sz_XDx3nvZc80g0RZ5bOr6jr6g>,
it says if you don't add 'privileged' to your Vagrantfile, by default it
will execute the shell script as root user.
I propably used wrong words to explain myself so that you couldn't
understand what I mean, let me clarify that. The shell script throws
exceptions like 'operation not permitted' all the way. I decided to copy
one line from shell script, like 'apt-get update'.
I gone into VAGRANT SSH, I typed SUDO APT-GET UPDATE, then he said,
OPERATION NOT PERMITTED, (Writing in uppercase just to make it more
readable between words, it looks so regular in normal way lol)
So I'm saying that I can't use root priorities even if I type SUDO... I
tried to delete this lock file. I wrote ' SUDO RM -F
/PATH/TO/LOCK/FILE/LOCK' and guess what, OPERATION NOT PERMITTED LOL
When I do this on my personal machine which is Linux Mint, I can do this.
How is this even possible...
Here is my Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
config.cache.auto_detect = true
end
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.hostname = "vagrant"
config.vm.network "private_network", ip: "192.168.50.4"
config.vm.synced_folder "..", "/var/www/3fcampus", :nfs => true
config.vm.network "forwarded_port", guest: 80, host: 8901
config.vm.network "forwarded_port", guest: 3306, host: 3313
config.vm.network "forwarded_port", guest: 1080, host: 1084
end
Here is my shell script, there are some sayings in my language, Turkish,
but they are just comments like 'Downloading blah blah'. Don't mind.
#!/bin/bash
# install php, mysql, mailcatcher
echo "Gerekli paketler kuruluyor..."
apt-get update
apt-get install -y python-software-properties
add-apt-repository ppa:ondrej/php5-oldstable
add-apt-repository ppa:nginx/stable
apt-add-repository ppa:ondrej/mysql-5.6
apt-get update
apt-get install -y php5 php5-mysql php5-cli php5-sqlite php5-mcrypt curl
php5-xsl php5-fpm php5-curl php5-gd php5-dev make build-essential sqlite3
libsqlite3-dev libxrender1 libfontconfig1 git nginx
export DEBIAN_FRONTEND=noninteractive
apt-get install -q -y mysql-server-5.5
echo "Mailcatcher kuruluyor..."
cd /vagrant/mailcatcher
gem install --local mailcatcher-0.5.12.gem
echo "Twig Konfigürasyonu yapılıyor..."
cd /var/www/3fcampus/dispatch/Twig-1.18.1/ext/twig
phpize
./configure
make
sudo make install
echo "Konfigurasyonlar yapılıyor..."
rm -f /etc/php5/fpm/php.ini
cp /vagrant/php.ini /etc/php5/fpm/php.ini
rm -f /etc/mysql/my.cnf
cp /vagrant/my.cnf /etc/mysql/my.cnf
rm -f /etc/php5/fpm/pool.d/www.conf
cp /vagrant/www.conf /etc/php5/fpm/pool.d
ln -s /vagrant/nginx-vhosts/phoenix /etc/nginx/sites-enabled
ln -s /vagrant/nginx-vhosts/people /etc/nginx/sites-enabled
ln -s /vagrant/nginx-vhosts/dispatch /etc/nginx/sites-enabled
ln -sf /vagrant/hosts /etc/hosts
# project installation
echo "Veritabanı yükleniyor..."
echo "CREATE DATABASE 3fcampus" | mysql -u root
echo "CREATE DATABASE 3fcampus_forms" | mysql -u root
echo "create user 'root'@'10.0.2.2' identified by ''" | mysql -u root
echo "grant all privileges on *.* to 'root'@'10.0.2.2' with grant option" |
mysql -u root
echo "flush privileges" | mysql -u root
echo "SET @@global.sql_mode = ''" | mysql -u root
echo "Phoenix veritabanı yükleniyor..."
mysql -u root 3fcampus_forms < "/var/www/3fcampus/ahep_forms.sql"
echo "Composer indiriliyor..."
cd /var/www/3fcampus/laravel
curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin
composer.phar install --prefer-dist
echo "Servisler başlatılıyor..."
service php5-fpm restart
service nginx restart
service mysql restart
mailcatcher --http-ip=0.0.0.0
echo "Migrationlar çalıştırılıyor..."
php artisan migrate
php artisan db:seed
echo 'export PATH=$PATH:/var/www/3fcampus/laravel/vendor/bin' > /home/
vagrant/.bash_profile
echo "Kurulum bitti"
18 Mart 2016 Cuma 22:21:32 UTC+2 tarihinde Alvaro Miranda Aguilera yazdı:
>
> Hello,
>
> Welcome to Vagrant linux and all that stuff :D
>
> he lock error literally is just saying "this user can't do this.."
>
> With some practice and after lots of error you will learn to read what
> that means.. "the user your are using cant do .."
>
> So basically here, the command you are running is meant to be run as root
> and not as the user you are using
>
> sudo <command> should fix the issue.,
>
> the sudo need to be inside the script that is being run.
>
> If you can share your Vagranfile and the script that is being run, I can
> help you more.
>
> Alvaro.
>
>
>
> On Fri, Mar 18, 2016 at 11:50 AM, evrim Alacan <[email protected]
> <javascript:>> wrote:
>
>> Hi all, this is going to be my first question about linux since I just
>> started to use it. So tell me if I need to tell more for you to help me.
>>
>>
>> This is my uname -a: Linux EvrimAlacan 3.19.0-32-generic
>> #37~14.04.1-Ubuntu SMP Thu Oct 22 09:41:40 UTC 2015 x86_64 x86_64 x86_64
>> GNU/Linux
>>
>> I'm using VirtualBox version : 5.0.4_LinuxMintr102546
>>
>> Vagrant Version : Vagrant 1.8.1
>>
>>
>> Before Linux I was using my windows to do my work and then I decided to
>> dual-boot my computer into a linux, and I choosed Linux Mint because it
>> seems the best to me.
>> But unfortunately when I 'vagrant up', bootstrap.sh which does all the
>> job about configurations on guest machine, does nothing. Because of the
>> following problem:
>>
>> ==> default: E: Could not open lock file /var/lib/apt/lists/lock - open
>> (1: Operation not permitted)
>> ==> default: E: Unable to lock directory /var/lib/apt/lists/
>>
>> I know, this problem is about permissions. Also this error is all over
>> the command prompt since bootstrap.sh commits more installations and fails.
>> If I type 'sudo vagrant up', It will install all the packages, but as
>> expected the virtual machine will not show up because the owner will be the
>> 'root', not me.
>> Whatever I did, I couldn't solve this. I get into it with 'vagrant ssh'.
>> I tried to take the first line from 'bootstrap.sh' which is 'apt-get
>> update'. Tried to run it manually.
>> I typed 'sudo apt-get update', but It still gave me an error saying I
>> don't have permission. I tried this with 'sudo su' as well.
>>
>> Here is what I get with 'sudo visudo' on guest machine:
>>
>>
>> #
>> # This file MUST be edited with the 'visudo' command as root.
>> #
>> # Please consider adding local content in /etc/sudoers.d/ instead of
>> # directly modifying this file.
>> #
>> # See the man page for details on how to write a sudoers file.
>> #
>> Defaults env_reset
>> Defaults exempt_group=admin
>> Defaults
>> secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
>>
>> # Host alias specification
>>
>> # User alias specification
>>
>> # Cmnd alias specification
>>
>> # User privilege specification
>> root ALL=(ALL:ALL) ALL
>>
>> # Members of the admin group may gain root privileges
>> %admin ALL=(ALL) NOPASSWD:ALL
>>
>> # Allow members of group sudo to execute any command
>> %sudo ALL=(ALL:ALL) ALL
>>
>> # See sudoers(5) for more information on "#include" directives:
>>
>> #includedir /etc/sudoers.d
>>
>> I can't even delete the 'lock' file by any means, I tried everything.
>> Changing the parent permissions to 777, didn't work as well. I looked on
>> the internet about 'immutable' thing,
>> found a command to check the file whether it is immutable or not, but I
>> don't even have a permission for it, even if I'm root. I don't know whats
>> wrong...
>>
>> I much appreciate any help
>>
>>
>>
>>
>> --
>> This mailing list is governed under the HashiCorp Community Guidelines -
>> https://www.hashicorp.com/community-guidelines.html. Behavior in
>> violation of those guidelines may result in your removal from this mailing
>> list.
>>
>> GitHub Issues: https://github.com/mitchellh/vagrant/issues
>> IRC: #vagrant on Freenode
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Vagrant" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/vagrant-up/56c2d318-349f-4880-aada-4360ec3e4084%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/vagrant-up/56c2d318-349f-4880-aada-4360ec3e4084%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/223081ca-c8d7-4222-8631-7d78f2d1531b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.