Last active
April 20, 2020 12:11
-
-
Save emaV/307776319a9ca021493be7cdbbe537d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# LightSail launch script | |
# https://lightsail.aws.amazon.com/ls/docs/en_us/articles/lightsail-how-to-configure-server-additional-data-shell-script | |
#https://stackoverflow.com/questions/44082464/pass-wget-output-streamed-shell-script-to-bash-but-with-extra-arguments/44083517 | |
# https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/ | |
# wget -qO - SCRIPTURL | bash -s - "drupal" | |
set -x | |
if [ $# -ne 1 ]; then | |
echo 1>&2 Usage: $0 domain | |
exit 127 | |
fi | |
# Set Variables | |
stackRoot='/opt/dashboard' | |
appName='dashboard' | |
appRoot="${stackRoot}/apps/${appName}" | |
appRootWebRoot="${appRoot}/symfony/public" | |
webRoot="${appRoot}/htdocs" | |
##################### | |
# Reset permissions # | |
##################### | |
function resetPermissions() { | |
chown -R bitnami:daemon $1 | |
chmod -R g+w $1 | |
} | |
############### | |
# Create dirs # | |
############### | |
function createDirs() { | |
mkdir -p "${appRoot}" | |
mkdir -p "${appRoot}/symfony" | |
mkdir -p "${appRoot}/conf" | |
resetPermissions "${appRoot}/symfony/" | |
} | |
######################## | |
# Apache configuration # | |
######################## | |
function setApache() { | |
# Set symlink to application | |
ln -s "${appRootWebRoot}" "${webRoot}" | |
tmp=/tmp/$$.eof | |
# Create and edit the ${appRoot}/conf/httpd-prefix.conf file | |
cat << EOF > "${tmp}" | |
Alias /${appName}/ "${webRoot}/" | |
Alias /${appName} "${webRoot}" | |
Include "${appRoot}/conf/httpd-app.conf" | |
EOF | |
mv ${tmp} "${appRoot}/conf/httpd-prefix.conf" | |
# Create and edit the ${appRoot}/conf/httpd-app.conf file | |
cat << EOF > "${tmp}" | |
<Directory ${webRoot}> | |
Options +FollowSymLinks | |
AllowOverride All | |
<IfVersion < 2.3 > | |
Order allow,deny | |
Allow from all | |
</IfVersion> | |
<IfVersion >= 2.3> | |
Require all granted | |
</IfVersion> | |
</Directory> | |
EOF | |
mv ${tmp} "${appRoot}/conf/httpd-app.conf" | |
# Add conf line to master apache | |
sed -i.bak "#${appRoot}#d" /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf | |
echo "Include \"${appRoot}/conf/httpd-prefix.conf\"" >> /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf | |
# Restart apache | |
/opt/bitnami/ctlscript.sh restart apache | |
} | |
############################# | |
# Install bitnami-dashboard # | |
############################# | |
function installDashboard () { | |
echo 'installDashboard' | |
} | |
################### | |
# Setup Dashboard # | |
################### | |
function setupDashboard () { | |
echo 'setupDashboard' | |
# @TODO Setup .env.local | |
# Setup ssh keys | |
mkdir -p "${appRoot}/.ssh" | |
ssh-keygen -t rsa -N "" -f "${appRoot}/.ssh/id_rsa_git" -C "bitnami@${HOSTNAME}" | |
touch "${appRoot}/.ssh/known_hosts" | |
chown -R daemon:daemon "${appRoot}/.ssh" | |
} | |
### | |
# SSHd conf | |
## | |
function setupSSHd () { | |
echo 'setupSSHd' | |
# Set verbose debug | |
# sed '/^[^#]*LogLevel.*\(QUIET\|FATAL\|ERROR\|INFO\)/{s/^/# /;h;s/$/\nLogLevel VERBOSE/};${p;g;/./!{iLogLevel VERBOSE'$'\n;};D}' -i /etc/ssh/sshd_config | |
# systemctl restart ssh.service | |
# systemctl restart syslog-ng.service | |
} | |
createDirs | |
setApache | |
#installDashboard | |
#setupDashboard | |
echo "ouch" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment