Skip to content

Instantly share code, notes, and snippets.

@rizemon
Created August 25, 2021 03:19
Show Gist options
  • Save rizemon/7c8a30d51cf6f88ce0e2bd118cfa7953 to your computer and use it in GitHub Desktop.
Save rizemon/7c8a30d51cf6f88ce0e2bd118cfa7953 to your computer and use it in GitHub Desktop.
Script used to construct the submission zip file according to the assignment requirement (v1)
#!/bin/bash
# CS2106 Lab Assignment 1 Zip Build Script v1 by @rizemon
# ----------------------------------
# Colors (From https://gist.github.com/jonsuh/3c89c004888dfc7352be)
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'
NUSNET_ID=""
TMP=/tmp/cs2106_lab1
# Clear previous runs
echo -e "[*] Deleting old ${YELLOW}$TMP${NOCOLOR} if any..."
rm -rf $TMP
# Create folder structure
echo "[*] Creating folder structure..."
mkdir -p $TMP/ex2 $TMP/ex3 $TMP/ex5 $TMP/ex6
echo "[*] Copying required files in..."
# Copy ex2 files
cp ex2/node.c $TMP/ex2
# Copy ex3 files
cp ex3/function_pointers.c ex3/node.c ex3/ex3.c $TMP/ex3
# Copy ex5 files
cp ex5/check_system.sh $TMP/ex5
# Copy ex6 files
cp ex6/check_syscalls.sh $TMP/ex6
echo "[*] Preview of folder structure:"
echo -en "${GREEN}"
find $TMP/. | sort | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
echo -en "${NOCOLOR}"
CURR_DIR=$(pwd)
cd $TMP
echo -e "[*] Zipping up files and placing ${YELLOW}$NUSNET_ID.zip${NOCOLOR} into ${YELLOW}$CURR_DIR/ex7/${NOCOLOR} ..."
echo -en "${LIGHTBLUE}"
zip -r $CURR_DIR/ex7/$NUSNET_ID.zip ex2 ex3 ex5 ex6
echo -en "${NOCOLOR}"
cd $CURR_DIR
echo -e "[+] Completed! Now change your current working directory to ${YELLOW}$CURR_DIR/ex7/${NOCOLOR} to do the verification by running: ${RED}./check_zip.sh $NUSNET_ID.zip${NOCOLOR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment