-
Notifications
You must be signed in to change notification settings - Fork 3
/
tarball-checker.sh
49 lines (40 loc) · 1.72 KB
/
tarball-checker.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
#!/bin/bash
# Copyright (C) 2021 Muhammad Athallah
# This free document is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# REV04 Sun 21 Nov 2021 18:29:25 WIB
# REV03 Sun 21 Nov 2021 16:45:48 WIB
# REV02 Tue 19 Oct 2021 13:30:00 WIB
# REV01 Tue 19 Oct 2021 12:40:50 WIB
# START Tue 19 Oct 2021 11:02:45 WIB
read -p "Please enter the desired week to be checked (use two-digit format): " WEEK
# Get the GitHub username from the username of Linux
ACCNAME=$USER
# Remove temporary directory (if any)
rm -rf /tmp/tarball-grade/
# Make directories
mkdir /tmp/tarball-grade/
mkdir /tmp/tarball-grade/mygrade
mkdir /tmp/tarball-grade/benchmark
# Download mygrade
wget https://os.vlsm.org/Log/$ACCNAME.tar.bz2.txt -O /tmp/tarball-grade/$ACCNAME.tar.bz2.txt
gpg --decrypt /tmp/tarball-grade/$ACCNAME.tar.bz2.txt > /tmp/tarball-grade/$ACCNAME.tar.bz2
tar -xf /tmp/tarball-grade/$ACCNAME.tar.bz2 -C /tmp/tarball-grade/mygrade
# Download benchmark
wget https://cbkadal.github.io/os212/SandBox/TARBALL.tar.bz2 -O /tmp/tarball-grade/TARBALL.tar.bz2
tar -xf /tmp/tarball-grade/TARBALL.tar.bz2 -C /tmp/tarball-grade/benchmark
# Print grades
echo "### GRADES OF DW$WEEK ###"
echo "GRADE DETAILS | MYGRADE | BENCHMARK"
echo "-----------------------------------------------------"
for file in /tmp/tarball-grade/mygrade/DW$WEEK/*
do
FILENAME="${file##*/}"
FIRSTPART=$(printf '%-15s' "$FILENAME")
MYGRADE=$(cat $file)
SECONDPART=$(printf '%-16s' "$MYGRADE")
BENCHMARK=$(cat /tmp/tarball-grade/benchmark/DW$WEEK/$FILENAME)
THIRDPART=$(printf '%-16s' "$BENCHMARK")
echo "$FIRSTPART | $SECONDPART | $THIRDPART"
done