forked from devopsdays/devopsdays-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_sponsors.sh
executable file
·52 lines (36 loc) · 1.42 KB
/
create_sponsors.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
#!/bin/bash
set -e
# Get year
read -p "Enter your event year (default: $(date +"%Y")): " year
[ -z "${year}" ] && year='2016'
# Get city
read -p "Enter your city name: " city
city_slug=$(echo $city | tr '-' ' ' | tr -dc '[:alpha:][:blank:]' | tr '[:upper:]' '[:lower:]'| tr 'āáǎàãâēéěèīíǐìōóǒòöūúǔùǖǘǚǜü' 'aaaaaaeeeeiiiiooooouuuuuuuuu' | tr ' ' '-')
# Generate event slug
event_slug=$year-$city_slug
# Prompt for inputting sponsors
while [ 1 ]
do
echo "Adding new sponsors; use CTRL+C to stop..."
# Gather info
read -p "Enter sponsor name: " sponsorname
sponsor_slug=$(echo $sponsorname | tr '-' ' ' | tr -dc '[:alpha:][:blank:]' | tr '[:upper:]' '[:lower:]'| tr 'āáǎàãâēéěèīíǐìōóǒòöūúǔùǖǘǚǜü' 'aaaaaaeeeeiiiiooooouuuuuuuuu' | tr ' ' '-')
if [ -f ../data/sponsors/$sponsor_slug.yml ];
then
echo "Sponsor already exists"
exit 0
fi
read -p "Enter sponsor url: " url
[ -z "${url}" ] && url=''
read -p "Enter path to 200x200 PNG logo: " logo
[ -z "${logo}" ] && logo=''
# Populate data file
cp examples/sponsor.yml ../data/sponsors/$sponsor_slug.yml
sed -i '' "s/SPONSORNAME/$sponsorname/" ../data/sponsors/$sponsor_slug.yml
sed -i '' "s%URL%$url%" ../data/sponsors/$sponsor_slug.yml
# Set logo
cp "$logo" ../static/img/sponsors/$sponsor_slug.png
echo "Add this to ../data/events/"$event_slug".yml under sponsors:"
echo " - id: " $sponsor_slug
echo " level: theirlevel"
done