summary refs log tree commit diff stats
path: root/svc/handlers_test.go
Commit message (Expand)AuthorAgeFilesLines
* license notice at top of each fileBen Morrison2019-07-111-0/+19
* linter warning about func signatureBen Morrison2019-06-131-1/+1
* merged indexHandler with cssHandler, updated testsBen Morrison2019-06-111-4/+4
* closing test response bodies & readability improvementsBen Morrison2019-06-101-0/+31
* handler unit tests finishedBen Morrison2019-06-091-2/+21
* removed redundant codeBen Morrison2019-06-091-39/+9
* handler tests now more substantialBen Morrison2019-06-091-16/+66
* apiEndpointHandler now 404s invalid endpoints, better testing for itBen Morrison2019-06-091-8/+63
* explicit init of static assets and test template init were removed: redundantBen Morrison2019-06-091-0/+1
* enabled apiTagsHandler and apiTagsBaseHandler testsBen Morrison2019-06-061-2/+1
* updated tests to work with new project structureBen Morrison2019-06-061-2/+2
* fixed some import commentsBen Morrison2019-06-051-1/+1
* moved bulk of code to its own package to clean up source treeBen Morrison2019-06-051-0/+116
corator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/bin/bash

pkg_path=$1

www_root="/srv/www"
www_user="www"
www_group="www"

pkg_file="${pkg_path}/project"
pkg_rm="${pkg_path}/deleted"
pkg_files="${pkg_path}/files"

if [ ! -f ${pkg_file} ]; then
    echo "Deploy web: invalid pkg_file ${pkg_file}"
    exit 1
fi

pkg_name=$(head -1 ${pkg_file})
pkg_new=$(head -3 ${pkg_file} | tail -1)
pkg_new7=$(echo ${pkg_new} | cut -c1-7)

pkg_www="${www_root}/${pkg_name}"
pkg_back="${pkg_www}/backup_deploy"
pkg_last="${pkg_www}/.last_deploy"

if [ ! -d ${pkg_www} ]; then
    echo "Deploy web: invalid pkg_www ${pkg_www}"
    exit 1
fi

# first backup all data
if [[ ! $(ls ${pkg_www} | grep -v "backup_deploy") = "" ]]; then
    if [ ! -d ${pkg_back} ]; then
        sudo -u ${www_user} mkdir -p ${pkg_back}
    fi
    backup_file="${pkg_back}/${pkg_name}-$(date '+%Y-%j-%H-%M-%S').tar.gz"
    echo "Deploy web: making backup ${backup_file}"
    sudo -u ${www_user} tar --exclude ${pkg_back} --xattrs -zcpf ${backup_file} ${pkg_www}
fi

# remove files and directories that have been deleted
if [ -f ${pkg_rm} ]; then

    echo "Deploy web: files to delete:"
    # first we delete files
    while read deleted_file; do
        deleted_file="${pkg_www}/${deleted_file}"
        if [ -f ${deleted_file} ]; then
            echo "file      rm ${deleted_file}"
            rm ${deleted_file}
        fi
    done <${pkg_rm}

    # delete directories
    while read deleted_file; do
        deleted_file="${pkg_www}/${deleted_file}"
        if [ -d ${deleted_file} ]; then
            echo "file      rm ${deleted_file}"
            rm ${deleted_file}
        fi
    done <${pkg_rm}

fi

# copy new files to destination
if [ -d ${pkg_files} ]; then
    echo "Deploy web: cp from ${pkg_files} to ${pkg_www}"
    sudo -u ${www_user} cp -r ${pkg_files}/* ${pkg_www}
fi

echo ${pkg_new} > ${pkg_last}
echo "Deploy: scripts/deployweb.sh ${pkg_name} ${pkg_new7} deployed."

#remove temporary package
rm -r ${pkg_path}