#!/bin/bash
# CENG 202 - OS Lab Setup Script

# 1. Create the directory structure (7 total sub-folders)
mkdir -p os_sandbox/source_data
mkdir -p os_sandbox/results/backups
mkdir -p os_sandbox/executables
mkdir -p os_sandbox/system_root/bin
mkdir -p os_sandbox/system_root/etc

# 2. Create the data files using heredocs
cat << 'EOF' > os_sandbox/source_data/global_news.txt
The US government is located in Washington. Bursa is a city in Turkey. Bursa is very close to Istanbul where Bursa Ulu Mosque is the most famous. Near the Marmara Sea, Mudanya, Bursa is one of the gorgeous
districts. Bursa was the capital city of Ottoman empire for centuries. Uludag university and Mudanya Aq
universitylocated in Nilufer and Mudanya respectively. One of the most prestigious well-known figures of 
Bursa is Zeki Muren. Cavit Caglar is yet another person who was a Bursa deputy and businessman who 
contributed to the city. Some people call Bursa as Burtvin because of the population from Artvin, a city 
in Northwest of Turkey. Some attractions in Bursa worth to visit are Bursa Cable car, Bursa Clock tower, 
Green Mosque,Long Souk, Bursa Plain, Bursa Montain, Bursa Ataturk's house, Bursa Zoo. Bursa's soccer 
team uses green and white crocodile as its symbol
EOF

cat << 'EOF' > os_sandbox/source_data/user_registry.csv
ID,Name,City,Random,Age
101,Aylin,Bursa,500,21
102,Emre,Istanbul,150,23
103,Can,Bursa,900,20
EOF

echo "Directory structure and data files created."
echo "Press Enter to create the symbolic link..."
read 

# 3. Create the symbolic link
ln -sf ../source_data/global_news.txt os_sandbox/results/shortcut_to_news

# 4. Set initial files and permissions
touch os_sandbox/results/empty_log.txt
chmod 444 os_sandbox/source_data/global_news.txt

echo "Setup Complete. Students should now run: cd os_sandbox"
script -a os_sandbox/results/empty_log.txt
pwd

