<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def owncloud():
    '''Set up owncloud.

    Package 'owncloud' pulls package 'mysql' which asks for a password.
    '''
    hostname = re.sub(r'^[^@]+@', '', env.host)  # without username if any
    sitename = query_input(
                   question='\nEnter site-name of Your Owncloud web service',
                   default=flo('owncloud.{hostname}'), color=cyan)
    username = env.user

    fabfile_data_dir = FABFILE_DATA_DIR

    print(magenta(' install owncloud'))
    repository = ''.join([
        'http://download.opensuse.org/repositories/',
        'isv:/ownCloud:/community/Debian_7.0/',
    ])
    with hide('output'):
        sudo(flo('wget -O - {repository}Release.key | apt-key add -'))
        filename = '/etc/apt/sources.list.d/owncloud.list'
        sudo(flo("echo 'deb {repository} /' > {filename}"))
        sudo('apt-get update')
    install_packages([
        'owncloud',
        'php5-fpm',
        'php-apc',
        'memcached',
        'php5-memcache',
    ])

    # This server uses nginx. owncloud pulls apache2 => Disable apache2
    print(magenta(' disable apache'))
    with hide('output'):
        sudo('service apache2 stop')
        sudo('update-rc.d apache2 disable')

    print(magenta(' nginx setup for owncloud'))
    filename = 'owncloud_site_config.template'
    path = flo('{fabfile_data_dir}/files/etc/nginx/sites-available/{filename}')
    from_str = filled_out_template(path, username=username, sitename=sitename,
                                   hostname=hostname)
    with tempfile.NamedTemporaryFile(prefix=filename) as tmp_file:
        with open(tmp_file.name, 'w') as fp:
            fp.write(from_str)
        put(tmp_file.name, flo('/tmp/{filename}'))
    to = flo('/etc/nginx/sites-available/{sitename}')
    sudo(flo('mv /tmp/{filename} {to}'))
    sudo(flo('chown root.root {to}'))
    sudo(flo('chmod 644 {to}'))
    sudo(flo(' '.join([
            'ln -snf ../sites-available/{sitename}',
            '/etc/nginx/sites-enabled/{sitename}',
    ])))

    # php5 fpm fast-cgi config

    template = 'www.conf'
    to = flo('/etc/php5/fpm/pool.d/{template}')
    from_ = flo('{fabfile_data_dir}/files{to}')
    put(from_, '/tmp/')
    sudo(flo('mv /tmp/{template} {to}'))
    sudo(flo('chown root.root {to}'))
    sudo(flo('chmod 644 {to}'))

    template = 'php.ini'
    to = flo('/etc/php5/fpm/{template}')
    from_ = flo('{fabfile_data_dir}/files{to}')
    put(from_, '/tmp/')
    sudo(flo('mv /tmp/{template} {to}'))
    sudo(flo('chown root.root {to}'))
    sudo(flo('chmod 644 {to}'))

    sudo('service php5-fpm restart')

    sudo('service nginx reload')