This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupB3.sh
204 lines (179 loc) · 6.73 KB
/
setupB3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env bash
if [ $# -lt 3 ]
then
echo "Arguments needed: <user>@<server> webroot url-without-www"
echo "e.g. l33th4x0r@login.servershop.com www/ sitename.com"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $(dirname $DIR)
SERVERROOT=$(ssh $1 "pwd")
WEBROOT=$SERVERROOT/"$2"
# remove repo stuff if installed via git
rm -rf $(dirname $DIR)/.git
# Create git repo and ignore everything except user content and environment config
git init $DIR/..
cat > $DIR/../.gitignore <<- EOM
#/*
#/*/
#!/storage/app/
#!/.env
EOM
# Configure environment
cp $DIR/../.env.example $DIR/../.env
KEY=$(php -r "echo md5(uniqid()).\"\n\";")
sed -i '' -e 's/secret/'$KEY'/g' $DIR/../.env
$EDITOR $DIR/../.env
# Create dummy index page
mkdir -p $DIR/../storage/app/pages
cat > $DIR/../storage/app/pages/index.md <<- EOM
title: About
slug: useless
# [optional]
published: true
# [optional]
type: index
# [optional, get theme template based on name]
style: dark | light | default
# [optional, set css class based on name]
transparent: false | true
# [optional, set css class based on name]
-------
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-md-6">
<h1>Hello, world!</h1>
<p class="lead">This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p>
</div>
<div class="col-md-6 text-right">
<img class="img-circle-thumbnail" src="https://placeimg.com/480/480/tech" alt="placeholder+image">
</div>
</div>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row text-center">
<div class="col-md-12">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
</div>
</div> <!-- /container -->
<div class="container">
<!-- Example row of columns -->
<div class="row text-center">
<div class="col-md-4">
<img class="img-circle" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<img class="img-circle" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<img class="img-circle" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
</div>
</div>
EOM
# Create dummy post
mkdir -p $DIR/../storage/app/blog/`date +%Y/%m/%d`
cat > $DIR/../storage/app/blog/`date +%Y/%m/%d`/test.md <<- EOM
title: Blog post
language: English
category: Test-Category
tags: one, two, three
slug: URLified-title-here
# [optional]
modified: 2016-07-30
# [optional]
lead: intro
# [optional]
published: true
# [optional]
type: feature
# [optional, get theme template based on name]
style: dark | light | default
# [optional, set css class based on name]
transparent: false | true
# [optional, set css class based on name]
-------
###Test
This is my **markdown** content!
EOM
# Create dummy project
mkdir -p $DIR/../storage/app/projects/Category
cat > $DIR/../storage/app/pages/contact.md <<- EOM
title: Project One
slug:
# [optional]
date: 2016-07-30
[optional]
description: desc
# [optional]
list-title: Built with
list-content: Technology, more technology
published: true
# [optional]
type: software
# [optional, get theme template based on name]
style: dark | light | default
# [optional, set css class based on name]
transparent: false | true
# [optional, set css class based on name]
-------
Lorem ipsum
EOM
# Create dummy flat page
cat > $DIR/../storage/app/pages/contact.md <<- EOM
title: Contact
slug: contact
# [optional]
published: true
# [optional]
type: page
# [optional, get theme template based on name]
style: dark | light | default
# [optional, set css class based on name]
transparent: false | true
# [optional, set css class based on name]
-------
<p class="lead">Description...</p>
Testings
EOM
# Install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
# Populate DB
bash $DIR/populate-db.sh
# Set up key exchange with server
cat ~/.ssh/id_rsa.pub | ssh $1 'cat >> .ssh/authorized_keys'
# Set up git hooks and scripts on server and client
HOOK="#!/bin/sh
git --work-tree=$WEBROOT --git-dir=$SERVERROOT/repo/site.git checkout -f master
bash $WEBROOT/scripts/populate-db.sh"
ssh $1 "mkdir repo && cd repo && mkdir site.git && cd site.git && git init --bare && cd hooks && echo '$HOOK' > post-receive && chmod +x post-receive"
git remote add live ssh://$1$SERVERROOT/repo/site.git
# Set up apache redirect to public root
ACCESS="RewriteEngine On
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]"
ssh $1 "echo '$ACCESS' > $WEBROOT/.htaccess"
# Add first commit
git add -A && git commit -m "Set up repo"
echo "Now you need only to push to publish!"
cd - > /dev/null 2>&1