From 434c83791480fd1ffe55a20d124b72b48193fa8c Mon Sep 17 00:00:00 2001 From: harshithpabbati Date: Wed, 2 Oct 2019 18:36:31 +0530 Subject: [PATCH 1/5] Get Absolute Path in config --- attendance/config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/attendance/config b/attendance/config index 4664d6b..e33bbae 100755 --- a/attendance/config +++ b/attendance/config @@ -10,7 +10,8 @@ case "${unameOut}" in esac if [[ "$machine" = "Mac" ]];then - python3 "$HOME"/.attendance/attendance.py >/tmp/stdout.log 2>/tmp/stderr.log + username=$(logname) + python3 /Users/"$username"/.attendance/attendance.py >/tmp/stdout.log 2>/tmp/stderr.log else python3 /opt/attendance/attendance.py &> /opt/attendance/attendance.log From 214f77c2d3d5007cc30a7c71361a5902473e75ae Mon Sep 17 00:00:00 2001 From: harshithpabbati Date: Thu, 3 Oct 2019 17:53:07 +0530 Subject: [PATCH 2/5] Made Mac install script generic --- README.md | 12 ------------ attendance/attendance.py | 2 +- attendance/config | 3 +-- install.sh | 7 +++++-- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 45b77c6..b640361 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/attendance/attendance.py b/attendance/attendance.py index 5a21723..e8df892 100755 --- a/attendance/attendance.py +++ b/attendance/attendance.py @@ -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(): diff --git a/attendance/config b/attendance/config index e33bbae..0270678 100755 --- a/attendance/config +++ b/attendance/config @@ -10,8 +10,7 @@ case "${unameOut}" in esac if [[ "$machine" = "Mac" ]];then - username=$(logname) - python3 /Users/"$username"/.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 diff --git a/install.sh b/install.sh index f3e0ddd..a4bee8f 100755 --- a/install.sh +++ b/install.sh @@ -11,7 +11,9 @@ 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" @@ -35,7 +37,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, From 35c864e05ad90d9cffd83debaa94f26e06c4df30 Mon Sep 17 00:00:00 2001 From: Sandesh Ghanta Date: Sat, 12 Oct 2019 11:26:13 +0530 Subject: [PATCH 3/5] Fixed Mac install script MAC install script created ".attendance" in wrong place when multiple users exist and current user is not admin. --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a4bee8f..0067bf0 100755 --- a/install.sh +++ b/install.sh @@ -16,7 +16,7 @@ if [[ "$machine" = "Mac" ]]; then 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 @@ -57,4 +57,4 @@ rm install.sh # fetch creds from user and store them cd "$attendance_folder_path" sudo python3 get_and_save_credentials.py -cd ~ \ No newline at end of file +cd ~ From 11e481427bafe832171f98a49c2a02e9dc2e96a9 Mon Sep 17 00:00:00 2001 From: Markus Vogl Date: Mon, 14 Oct 2019 16:24:25 +0200 Subject: [PATCH 4/5] Fixed Support for Arch Linux #4 --- attendance/config.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 attendance/config.sh diff --git a/attendance/config.sh b/attendance/config.sh new file mode 100755 index 0000000..0270678 --- /dev/null +++ b/attendance/config.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +unameOut="$(uname -s)" +case "${unameOut}" in + Linux*) machine=Linux;; + Darwin*) machine=Mac;; + CYGWIN*) machine=Cygwin;; + MINGW*) machine=MinGw;; + *) machine="UNKNOWN:${unameOut}" +esac + +if [[ "$machine" = "Mac" ]];then + /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 + +fi From b56ec9c55614bba6bc647785cf1f4ff756c77870 Mon Sep 17 00:00:00 2001 From: Markus Vogl Date: Mon, 14 Oct 2019 16:28:17 +0200 Subject: [PATCH 5/5] Fixed Support for Arch Linux #4 --- attendance/config | 17 ----------------- install.sh | 13 ++++++++++--- 2 files changed, 10 insertions(+), 20 deletions(-) delete mode 100755 attendance/config diff --git a/attendance/config b/attendance/config deleted file mode 100755 index 0270678..0000000 --- a/attendance/config +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -unameOut="$(uname -s)" -case "${unameOut}" in - Linux*) machine=Linux;; - Darwin*) machine=Mac;; - CYGWIN*) machine=Cygwin;; - MINGW*) machine=MinGw;; - *) machine="UNKNOWN:${unameOut}" -esac - -if [[ "$machine" = "Mac" ]];then - /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 - -fi diff --git a/install.sh b/install.sh index 0067bf0..36b5430 100755 --- a/install.sh +++ b/install.sh @@ -18,9 +18,16 @@ if [[ "$machine" = "Mac" ]]; then pip3 install requests 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