Skip to content

Commit

Permalink
Fixes install bug with interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ribalba committed Oct 19, 2023
1 parent c612e0a commit 7b1e6aa
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You can use the `-f` parameter with a filename. Please submit the data in the pl
This is a description on how to set everything up if you did a git clone. You can also just do

```
curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/install.sh | sudo bash
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/install.sh)"
```
which will do the whole install for you.

Expand Down Expand Up @@ -132,7 +132,7 @@ We currently don't support an automatic update. You will have to:
- Rerun in the install script which will overwrite any custom changes you have made!
```
sudo mv /etc/hog_settings.ini /etc/hog_settings.ini.back
curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/install.sh | sudo bash
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/install.sh)"
```

## Contributing
Expand All @@ -141,6 +141,35 @@ PRs are always welcome. Feel free to drop us an email or look into the issues.

The hog is developed to not need any dependencies.

## Debugging

It sometimes help to enable debugging for the logger process you can do this by editing the `/Library/LaunchDaemons/berlin.green-coding.hog.plist` file:
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>berlin.green-coding.hog</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/hog/power_logger.py</string>
<string>-v</string>
<string>debug</string>
<string>-o</string>
<string>/tmp/hog.log</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
```
Please remember that the log file can become quite big. The hog does not use logrotate or similar out of the box.

## Screenshots

<img src="Screenshot.png" width="300"/>
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion app/hog/hog/InstallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct CopyPasteTextField: NSViewRepresentable {


struct TwoView: View {
@State private var text = "curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/install.sh | sudo bash"
@State private var text = "sudo bash -c \"$(curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/install.sh)\""

var body: some View {
Text("2) Run this command").font(.headline)
Expand Down
Binary file modified hog.app/Contents/MacOS/hog
Binary file not shown.
20 changes: 12 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ chmod +x /usr/local/bin/hog/power_logger.py
# Writing the config file
###

read -p "In order for the app to work with all features please allow us to upload some data. [Y/n]: " upload_data
upload_data=${upload_data:-Y}
upload_data=$(echo "$upload_data" | tr '[:upper:]' '[:lower:]')

if [[ $upload_data == "y" || $upload_data == "yes" ]]; then
upload_flag="true"
if [[ -t 0 ]]; then # Check if input is from a terminal
read -p "In order for the app to work with all features please allow us to upload some data. [Y/n]: " upload_data
upload_data=${upload_data:-Y}
upload_data=$(echo "$upload_data" | tr '[:upper:]' '[:lower:]')

if [[ $upload_data == "y" || $upload_data == "yes" ]]; then
upload_flag="true"
else
upload_flag="false"
fi
else
upload_flag="false"
upload_flag="true"
fi

cat > /etc/hog_settings.ini << EOF
Expand All @@ -89,7 +93,7 @@ echo "Configuration written to /etc/hog_settings.ini"

mv -f /usr/local/bin/hog/berlin.green-coding.hog.plist /Library/LaunchDaemons/berlin.green-coding.hog.plist

sed -i '' "s|PATH_PLEASE_CHANGE|/usr/local/bin/hog/|g" /Library/LaunchDaemons/berlin.green-coding.hog.plist
sed -i '' "s|PATH_PLEASE_CHANGE|/usr/local/bin/hog|g" /Library/LaunchDaemons/berlin.green-coding.hog.plist

chown root:wheel /Library/LaunchDaemons/berlin.green-coding.hog.plist
chmod 644 /Library/LaunchDaemons/berlin.green-coding.hog.plist
Expand Down

0 comments on commit 7b1e6aa

Please sign in to comment.