Skip to content

Instantly share code, notes, and snippets.

@196Ikuchil
196Ikuchil / uploader.php
Created August 12, 2019 14:58
interKosenctf2019
<?php
ini_set('display_errors', 0);
// reset challenge environment hourly
if (!file_exists('../hourly') || (time() - filemtime('../hourly')) > 60*60) {
// remove uploaded files
foreach (glob('../files/*') as $f) {
unlink("../files/$f");
}
@196Ikuchil
196Ikuchil / main.tf
Created July 17, 2019 02:21
terraform カレンダーアプリの設定
variable "aws_access_key" {}
variable "aws_secret_key" {}
variable "aws_db_username" {}
variable "aws_db_password" {}
resource "aws_key_pair" "calendar-ssh" {
key_name = "xxxxxxxxxxx-key"
public_key = "${var.aws_pub_key}"
}
@196Ikuchil
196Ikuchil / default.rb
Created July 4, 2019 05:00
itamae cookbooks/mysql/default.rb
libraries = %w[mysql56 mysql-community-client mysql-community-devel]
execute "sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm -y"
libraries.each do |l|
package l do
action :install
end
end
@196Ikuchil
196Ikuchil / default.rb
Last active July 4, 2019 04:23
itamae cookbooks/ruby/default.rb
include_recipe "../../environments/default.rb"
include_recipe "rbenv::system"
remote_file "/etc/profile.d/rbenv.sh" do
action :create
mode "664"
owner "root"
group "root"
source "./etc/profile.d/rbenv.sh"
end
@196Ikuchil
196Ikuchil / default.rb
Created July 4, 2019 04:06
itamae cookbooks/environments/default.rb
USER_NAME = "mycalendar".freeze
node.reverse_merge!(
root: {
name: "root",
owner: "root",
group: "root",
},
user: {
name: USER_NAME.to_s,
@196Ikuchil
196Ikuchil / default.rb
Created July 4, 2019 03:55
itamae cookbooks/users/mycalendar/default.rb
USER_NAME = node[:user][:name]
HOME_DIR = "/home/#{USER_NAME}".freeze
group USER_NAME.to_s do
action :create
gid 502
end
user USER_NAME.to_s do
action :create
@196Ikuchil
196Ikuchil / imagemagick.rb
Created July 4, 2019 03:38
itamae cookbooks/dependencies/imagemagick.rb
image_magic_dep = %w[libpng-devel libjpeg-devel libtiff-devel]
image_magic_dep.each do |i|
package i do
action :install
end
end
directory "create Download directory" do
action :create
path "/tmp/Download"
@196Ikuchil
196Ikuchil / default.rb
Created July 4, 2019 03:33
itamae cookbooks/dependencies/default.rb
include_recipe "../../environments/default.rb"
dependencies = %w[git gcc gcc-c++ wget]
execute "yum update" do
command "yum update -y"
end
dependencies.each do |p|
package p do
include_recipe "../cookbooks/dependencies/default.rb"
include_recipe "../cookbooks/users/default.rb"
include_recipe "../cookbooks/ruby/default.rb"
include_recipe "../cookbooks/mysql/default.rb"
include_recipe "../cookbooks/nginx/default.rb"
include_recipe "../cookbooks/nodejs/default.rb"
include_recipe "../cookbooks/rails/default.rb"
@196Ikuchil
196Ikuchil / database.yml
Created June 20, 2019 11:11
config/database.yml aws RDB
default: &default
adapter: mysql2
encoding: utf8
database: mycalendar_development
pool: 5
username: <%= Settings.database[:user_name] %>
password: <%= Settings.database[:password] %>
socket: /var/lib/mysql/mysql.sock
reconnect: false
host: calendar-dbinstance.xxxx.xxxxx.rds.amazonaws.com