Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Fix arch (pacman-based system) support #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ Run the following command in your terminal and then, enter your amFOSS CMS Crede
wget https://raw.githubusercontent.com/amfoss/attendance-tracker/master/install.sh -O install.sh ; bash -e install.sh
```

## For Mac

You have add your absolute path in 3 places after running the above command
```
* config
* install.sh
* attendance.py
```

To get Absolute path just
```pwd```

## Update Your Credentials
This should be done whenever you change your password.

Expand Down
2 changes: 1 addition & 1 deletion attendance/attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if _platform == "linux" or _platform == "linux2":
file_path = "/opt/attendance/"
elif _platform == "darwin":
file_path = f"{expanduser('~')}/.attendance/"
file_path = f"/Users/{sys.argv[1]}/.attendance/"


def get_credentials():
Expand Down
2 changes: 1 addition & 1 deletion attendance/config → attendance/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ case "${unameOut}" in
esac

if [[ "$machine" = "Mac" ]];then
python3 "$HOME"/.attendance/attendance.py >/tmp/stdout.log 2>/tmp/stderr.log
/usr/local/bin/python3 /Users/"$1"/.attendance/attendance.py "$1" >/tmp/stdout.log 2>/tmp/stderr.log
else
python3 /opt/attendance/attendance.py &> /opt/attendance/attendance.log

Expand Down
24 changes: 17 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@ esac

# install pip, git and requests
if [[ "$machine" = "Mac" ]]; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
if [[ $(command -v brew) == "" ]]; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew install python3
pip3 install requests
readonly attendance_folder_path="$HOME/.attendance"
readonly attendance_folder_path="/Users/$(logname)/.attendance"
else
sudo apt install python3-pip git -y
sudo -H pip3 install requests
readonly attendance_folder_path="/opt/attendance"
if [[ $(command -v pacman) == "" ]]; then
# linux install (no arch linux)
sudo apt install python3-pip git -y
sudo -H pip3 install requests
readonly attendance_folder_path="/opt/attendance"
else
# arch linux install, python3 is default python, iwlist is in core/wireless_tools
sudo pacman -S git python-requests wireless_tools
readonly attendance_folder_path="/opt/attendance"
fi
fi

# clone the repo
Expand All @@ -35,7 +44,8 @@ sudo cp -r attendance-tracker/attendance/. "$attendance_folder_path"/.
sudo chmod +x "$attendance_folder_path"/config "$attendance_folder_path"/get_ssid_names.sh

# Add a new cron-job
croncmd="*/1 * * * * ${attendance_folder_path}/config"
username=$(logname)
croncmd="*/1 * * * * ${attendance_folder_path}/config $username"
# write out current crontab
sudo crontab -l > mycron || touch mycron
# echo new cron into cron file if it does not exist,
Expand All @@ -54,4 +64,4 @@ rm install.sh
# fetch creds from user and store them
cd "$attendance_folder_path"
sudo python3 get_and_save_credentials.py
cd ~
cd ~