Skip to content

Commit

Permalink
Extra cli verbosity of user
Browse files Browse the repository at this point in the history
  • Loading branch information
actuallymentor committed Sep 21, 2022
1 parent 649e1ab commit 80533d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/modules/battery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { exec } = require('node:child_process')
const sudo = require( 'sudo-prompt' )
const { log, alert } = require( './helpers' )

const { USER } = process.env
const path_fix = 'PATH=$PATH:/usr/local/bin/battery'
const battery = `${ path_fix } battery`
const shell_options = {
Expand Down Expand Up @@ -80,9 +80,9 @@ const update_or_install_battery = async () => {

// If not installed, run install script
if( !is_installed ) {
log( `Installing battery...` )
log( `Installing battery for $USER...` )
await alert( `Welcome to the Battery limiting tool. The app needs to install some components, so it will ask for your password. This should only be needed once.` )
const result = await exec_sudo_async( `curl -s https://raw.githubusercontent.com/actuallymentor/battery/main/setup.sh | bash -l` )
const result = await exec_sudo_async( `curl -s https://raw.githubusercontent.com/actuallymentor/battery/main/setup.sh | bash -s -- $USER` )
log( `Install result: `, result )
}

Expand Down
7 changes: 5 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ tempfolder=~/.battery-tmp
binfolder=/usr/local/bin
mkdir -p $tempfolder

# Set script value
calling_user=${1:="$USER"}

# Ask for sudo once, in most systems this will cache the permissions for a bit
sudo echo "🔋 Starting battery installation"

Expand All @@ -35,9 +38,9 @@ sudo chmod u+x $binfolder/smc
bateryfolder="$tempfolder/battery"
echo "[ 5/9 ] Cloning battery repository"
git clone --depth 1 https://github.com/actuallymentor/battery.git $bateryfolder &> /dev/null
echo "[ 6/9 ] Writing script to $binfolder/battery"
echo "[ 6/9 ] Writing script to $binfolder/battery for user $calling_user"
sudo cp $bateryfolder/battery.sh $binfolder/battery
sudo chown $USER $binfolder/battery
sudo chown $calling_user $binfolder/battery
sudo chmod 755 $binfolder/battery
sudo chmod u+x $binfolder/battery

Expand Down

0 comments on commit 80533d5

Please sign in to comment.