frontend/app/models/app.rb in meroku-2.0.7 vs frontend/app/models/app.rb in meroku-2.0.8
- old
+ new
@@ -2,13 +2,29 @@
belongs_to :user
after_commit :make_folder, on: [:create]
def make_folder
+ username = self.user.token
Rails.logger.debug "DB8 app.rb:def self.make_folder called"
- system(%Q[sudo -u git mkdir /home/git/#{self.name}.git])
- system(%Q[sudo -u git sh -c "cd /home/git/#{self.name}.git; git --bare init"])
- system(%Q[sudo -u git sh -c "echo '#!/bin/bash' >> /home/git/#{self.name}.git/hooks/post-receive"])
- system(%Q[sudo -u git sh -c 'echo "echo abc123499999999999999999999999999999" >> /home/git/#{self.name}.git/hooks/post-receive'])
- system(%Q[sudo -u git sh -c 'sudo chmod +x /home/git/#{self.name}.git/hooks/post-receive'])
+ system(%Q[sudo -u #{username} mkdir /home/#{username}/#{self.name}.git])
+ system(%Q[sudo -u #{username} mkdir /home/#{username}/#{self.name}])
+ system(%Q[sudo -u #{username} sh -c "cd /home/#{username}/#{self.name}.git; git --bare init"])
+
+
+ system(%Q[sudo -u #{username} sh -c "echo '#!/bin/bash
+set -x
+: Git hook is executing
+mkdir /home/#{username}/#{self.name}
+cd /home/#{username}/#{self.name}
+cp /sharedro/etc_nginx_sites-enabled_template /home/#{username}/#{self.name}.conf
+sed -i -e 's/REPLACEMEAPPNAME/#{self.name}/g' /home/#{username}/#{self.name}.conf
+sed -i -e 's/REPLACEMEUSERNAME/#{username}/g' /home/#{username}/#{self.name}.conf
+git --work-tree=/home/#{username}/#{self.name} --git-dir=/home/#{username}/#{self.name}.git checkout -f
+bundle install --path vendor/bundle
+RAILS_ENV=production bundle exec rake db:migrate
+RAILS_ENV=production bundle exec rake assets:precompile
+RAILS_ENV=production bundle exec puma -d -b unix:///home/#{username}/#{self.name}.sock
+' > /home/#{username}/#{self.name}.git/hooks/post-receive"])
+ system(%Q[sudo -u #{username} sh -c 'chmod u+x /home/#{username}/#{self.name}.git/hooks/post-receive'])
end
end