WebFaction
Community site: login faq

I've been trying to create my own custom install script to create a Laravel 4 application quickly and easily. The problem is, it always seems to fail - no actual explanation is given short of "There was an error creating the app with the custom script." (which in itself is a useless error description...)

The script seems to complete up to about line 30. Anything after that point isn't ran. If anybody has any ideas about why this may be happening, I'd love to hear them. Here's the script:

-----BEGIN WEBFACTION INSTALL SCRIPT-----
#!/usr/local/bin/python2.4

"""
Laravel Installer

This installer installs a basic setup of the current Laravel stable release using Composer so you can get your development started right away.

2 Applications will be created - one given the name you specify, and the other the name appended with "_symlink". This latter application will point to the public directory and is the one you should point your website entry at.

"autostart": not applicable
"extra info":
"""

import sys
import xmlrpclib

def create(account, app_name, autostart, extra_info, password, server, session_id, username):
    app = server.create_app(session_id, app_name, 'static_php54', False, '')
    # Grab composer.phar, grab the composer.json file from the repo
    cmd = ''
    cmd += 'rm index.html;'
    cmd += 'curl -sS https://getcomposer.org/installer | php54;'
    cmd += 'wget https://github.com/laravel/laravel/archive/master.zip --output-document=laravel.zip > /dev/null 2>&1;'
    cmd += 'unzip laravel.zip > /dev/null 2>&1;'
    cmd += 'rm laravel.zip;'
    cmd += 'mv laravel-master/* .;'
    cmd += 'rm -Rf laravel-master;'
    server.system(session_id, cmd)

    # Replace the app name in the composer.json file
    composer_json_path = '/home/%s/webapps/%s/composer.json' % (username, app_name)
    server.replace_in_file(session_id, composer_json_path, ('php', 'php54'))

    # Run composer install
    cmd = ''
    cms += 'php54 composer.phar install --prefer-dist --no-progress;'
    server.system(session_id, cmd)

    # Create a symlink application to the /public/ directory
    symlink_app_name = "%s_symlink" % (app_name)
    symlink_app_path = "/home/%s/webapps/%s/public" % (username, app_name)

    symlink_app = server.create_app(session_id, symlink_app_name, 'symlink54', False, symlink_app_path)

    print app['id']

def delete(account, app_name, autostart, extra_info, password, server, session_id, username):
    server.delete_app(session_id, app_name)
    server.delete_app(session_id, "%s_symlink" % (app_name))

if __name__ == '__main__':
    action, username, password, machine, app_name, autostart, extra_info = sys.argv[1:]
    server = xmlrpclib.Server('https://api.webfaction.com/')
    session_id, account = server.login(username, password, machine)

    locals()[action](account, app_name, autostart, extra_info, password, server, session_id, username)
-----END WEBFACTION INSTALL SCRIPT-----

asked 23 Sep '13, 16:44

euantorano
1327
accept rate: 0%

edited 23 Sep '13, 16:45


More than likely the error is here:

cmd = ''
cms += 'php54 composer.phar install --prefer-dist --no-progress;'

You are trying to add to an undefined variable "cms", which I assume is a typo for "cmd".

permanent link

answered 23 Sep '13, 19:56

waynek
4254
accept rate: 27%

Good spot, but the script seems to fail before it even reaches that point as the file is not edited.

(25 Sep '13, 10:40) euantorano
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×102
×75

question asked: 23 Sep '13, 16:44

question was seen: 2,571 times

last updated: 25 Sep '13, 10:40

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM