Mac app Packages - Running pre-installation script issues - bash

So I'm using the packages app : http://s.sudre.free.fr/Software/Packages/about.html
Running a pre-installation script for my package that does something simple such as
#!/bin/sh
cd ~/Desktop
mkdir test_folder
exit 0
Gives me no issues, creates the folder and installation is successful. (It is a dummy app/package and I am only testing to make sure I can get the installation script to work).
However, when I try to test the actual content I want to install for the user, it says the installation is successful but nothing happens.
#!/bin/sh
export GOPATH=~/gocode
export PATH=$PATH:$GOPATH/bin
go get -d github.com/lightningnetwork/lnd
cd $GOPATH/src/github.com/lightningnetwork/lnd
make && make install
exit 0
I'm not sure if my script is incorrect? Do I have to use only native bash commands because I am aware that go & get aren't traditional bash commands. I'm really confused because this script works 100% fine when running normally & as admin through the terminal yet gives me issues when using the Packages App.
I'm totally open to achieving this installation a different way (not using Packages or having to do a different script approach).
An alternative I was thinking was to create an Electron Menu Bar app that would run the same script, but I'm not sure if this would work either.
Thank you so much for your help!

Related

How to install Golang on chrome os

I tried the method from https://go.dev/doc/install and I keep getting "-bash: go: command not found".
I tried https://gist.github.com/conoro/4fca191fad018b6e47922a21fab499ca but I dont know what command to run when I get to the "Use sftp or scp on the ARM64 device to get the tar.gz file" stage. Any help???
You don't need to compile from source in Developer mode, you can just use the Chromebrew-provided version.
If your Chromebook is relatively new, you can enable the Linux VM now built into ChromeOS to install Go without developer mode. Follow the steps from the following Google Support article to enable this feature- https://support.google.com/chromebook/answer/9145439. This has been tested on a Samsung Chromebook Plus on version 71.0.3578.127. If this feature is not available for you, you will need to enable Developer Mode.
This tutorial will show you how to install, build, and run Go on Chrome OS.
Please note this has only been tested on a 64GB LTE Pixel, however it should work on other Chromebooks. Note that enabling developer mode reduces the security guarantees offered by Chrome OS.
Install Go
First download the latest version of Go for Linux from the Go Downloads page.
After that, open a shell by hitting (CTRL+ALT+T) and typing in shell then hit enter. Then extract it using the following command (when replacing < Go Linux package > with the name of the file you downloaded):
sudo tar xpvf ~/Downloads/< Go Linux package > -C /usr/local
Go should now be installed you can test this by typing /usr/local/go/bin/go. If it installed correctly, you should see the Go help prompt. Go is now installed.
Create a Workspace
To keep this simple just create a folder called /usr/local/go/work. Also, create a folder called src inside /usr/local/go/work/.
Set PATH
Add the following to ~/.bashrc:
export GOPATH="/usr/local/go/work"
export PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin"
This will allow you to run your Go programs in your shell.
Test if it worked
First create a folder inside of your /usr/local/go/src folder. After that create a file in your folder called hello.go with the following in it:
package main
import "fmt"
func main() {
fmt.Println("Hello, Chrome OS!")
}
Now, run go install hello. Then, run ${GOPATH}/bin/hello (or just hello if you setup your GOPATH above) and you should see Hello, Chrome OS!.
Collected from : https://github.com/golang/go/wiki/ChromeOS
If you want to download Go on a Chromebook in Dev Mode, without installing Linux follow these steps:
Enable Dev mode, in case you have not already.
Download the latest version of Go for Linux (https://go.dev/dl/)
IN YOUR TERMINAL
Type Shell
mkdir ~/Coding
tar -xzf ~/Downloads/ADD YOUR VERSION HERE -C ~/Coding/
echo "sudo mount -i -o remount,exec /home/chronos/user/" >> ~/.bash_profile
echo "sudo mount -i -o remount,exec /tmp/" >> ~/.bash_profile
SET ENV VARIABLES
export GOROOT=~/CS/go *Where you extracted Go*
export GOPATH=~/Downloads/go *Where you wanna keep your Go projects*
PATH=$PATH:$GOROOT/bin:$GOPATH/bin *This adds everything to PATH*
To make sure everything works restart your Terminal and type go version you should see the version you installed

Why /user/local/go isn't recognized as a Go SDK in GoLand

I'm trying to setup GoLand to use WSL 2 as in this guide: https://www.jetbrains.com/help/go/how-to-use-wsl-development-environment-in-product.html
I've installed Go in the Ubuntu distro following the linux instructions on the GoLang website, and go version prints outs the version I downloaded, so it appears that Go is working inside WSL.
So now I tried to create a new project in GoLand, and I'm getting errors, which appear to come from the fact that the SDK isn't loaded in GoLand. The guide doesn't offer much guidance on this, so I just tried to add a local SDK.
When I select /usr/local/go I get an error that it's not a valid SDK.
So I created the ~/go directory, and then updated my .zshrc file to export the GOPATH and GOROOT environment variables, even though they already showed up when I ran go env, doing this got them to show up on a simple env call.
But I'm still getting the invalid SDK error like above.
Is there a configuration step I'm missing that isn't spelled out in the guide? I came across this old post about creating symlinks to fake the expected directory structure. I haven't done this because it's a really old post, has comments that say this has been fixed, and seems like a really odd solution.
Support for Go SDK in WSL2 will be available in the next 2021.3 release, please see GO-10618.
October 2021 update.
2021.3 reaches Early Access Program at the moment. GoLand suggests selecting Go SDK on WSL2 mount if the location of the project is on WSL2 as well.
I experienced this on my Debian machine and I wasn't using WSL2. I found that the actual cause of the issue is that Goland is unable to read the directory /usr/local/go/bin due to inadequate permission.
A possible solution is to run the goland.sh script as root. The script can be found in the bin/goland.sh directory of the Goland IDE folder. Here is a simple command to do run Goland as the root
export HISTIGNORE='*sudo -S*' && echo "sudo-password-here" | sudo -S /absolute-path-to-goland.sh
export HISTIGNORE='*sudo -S*' tells bash history to ignore caching any command matching sudo -S* to bash history. This way, your sudo-password isn't saved into the bash-history file.
echo "sudo-password-here" | pipes your sudo password as input to the next command.
sudo -S tells bash to read input for password prompt from stdin, which has been provided through the echo command.
Alternatively, you can just install the latest version of Goland. Hopefully, it doesn't come with this bug

Running "pod install" in automator action in Mac OS - Permission denied

I am currently grading approx 50 apps created by students whereas most of them use CocoaPods in their projects and I'm spending an awful lot of time just navigating in the terminal to different folders just to run "pod install". I googled a bit and found this page:
https://medium.com/#abhishekbedi/podfile-right-click-pod-install-5da88c89c907
Which is exactly what I want, but of course it doesn't work on my computer. I am not proficient in Terminal at all and I can't figure out what I'm missing, any help much appreciated!
Here's what I have in the automator action right now:
#!/bin/bash
file=$1
POD="/usr/local/bin/pod"
folder=dirname $file
cd $folder
LANG=en_US.UTF-8 $POD install
, which results in the following error:
Task ”Run command script” encountered an error: ”-: line 3: /Users/.../Podfile: Permission denied”
Maybe I got the text a bit wrong, I just translated it from Swedish.
I've tried chmod on /usr/local/bin/pod and both the file and folders (probably shouldn't have done that), but the error just got worse.
I want all necessary handling inside the script, since any terminal action would defeat the purpose of not having to use the terminal..
Ideas? Thanks

How to open gnuplot from mobaxterm?

I'm not sure how to open Gnuplot from MobaXterm. I've been trying many different commands but they all don't work. When I try, I get the same error.
-bash: gnuplot: command not found
I'm curious if I downloaded Gnuplot to the wrong part of the computer or if I'm not getting the command right? I'm trying to write a program in shell script that opens Gnuplot on it's own and plots data through the shell script.
Any help is appreciated!
mobaxterm is not a linux server. So you cant install packages into it normally.
you must download plugins if you can find the plugin you are looking for
check their list here
http://mobaxterm.mobatek.net/plugins.html
and it seems gnuplot is not there .
in this case your easiest solution is to download cygwin and add gnuplot on it which is possible
other option is to run small virtual machine so you can test on it
in all cases mobaxterm is not real linux enviroment so to be sure your shel do work on normal linux machines you will need to develop and test on real linux
You can install the winbuild of gnuplot and add the path to the bin directory, with gnuplot.exe in it, to mobaxterm's PATH (probably set it in .initrc or .bashrc, whichever you prefer).
MobaXterm is a standalone program which 'emulates' a Linux terminal but has no idea about your frame system (e.g. your Windows and your programs). So if you type 'gnuplot' Moba has no idea what is this. You have to
change the current directory to where is wgnuplot.exe e.g.:
cd /drives/c/Program\ Files/gnuplot-4/bin
./wgnuplot.exe
or run directly it:
/drives/c/Program\ Files/gnuplot-4/bin/wgnuplot.exe
or change your $PATH:
PATH=$PATH:/drives/c/Program\ Files/gnuplot-4/bin
wgnuplot.exe
or create a script named 'gnuplot' which runs wgnuplot.exe
#File name: 'gnuplot'
#!/bin/sh
/drives/c/Program\ Files/gnuplot-4/bin/wgnuplot.exe
and place it into some $PATH directory:
`/bin` or `/usr/bin` or `/drives/c/WINDOWS` or `/drives/c/WINDOWS/system32`
or... :)
The simplest way I found out is to use the Moba Package Manager to install the win version of gnuplot.
Open MobaXterm and type MobApt. An GUI will open up and you can type in "gnuplot" in the filter field.
Just select and install the package, MobApt will take care of any dependencies for you.

OSX Equivalent of WinSCP's Fully-Automated Local-Remote SFTP Sync?

I fondly remember working with WinSCP and using the fully automated local-to-remote syncing functionality, where the app would monitor a directory hierarchy and send changes to the remote server as they happened.
Is there an app available on OSX that accomplishes the same thing? I haven't really been able to find anything. When I do find something promising, it always turns out to be a traditional syncing app, where you need to initiate the sync command manually and it then scans the hierarchy to find changed files. That takes too long and isn't automated.
Been looking at the File System Events API, wondering if a small app could be pieced together with a small utility to trigger hierarchy changes and feed the changed directory to rsync or something.
Thanks for any leads!
There are two Mac-specific utilities you may be able to utilize to make your job easier:
Automator (link and link)
Folder Actions (link link and link)
Both tools have AppleScript as a common thread (which can be used to execute shell commands). You might be able to write a small AppleScript that is launched when a folder changes to call rsync and perform the service you require.
Well, I had the same kind of problem and it is possible using these together: rsync, SSH Passwordless Login, Watchdog (a Python sync utility) and Terminal Notifier (an OS X notification utility made with Ruby. Not needed, but helps to know when the sync has finished).
I created the key to Passwordless Login using this tutorial from Dreamhost wiki: http://cl.ly/MIw5
1.1. When you finish, test if everything is ok… if you can't Passwordless Login, maybe you have to try afp mount. Dreamhost (where my site is) does not allow afp mount, but allows Passwordless Login. In terminal, type:
ssh username#host.com
You should login without passwords being asked :P
I installed the Terminal Notifier from the Github page: http://cl.ly/MJ5x
2.1. I used the Gem installer command. In Terminal, type:
gem install terminal-notifier
2.3. Test if the notification works.In Terminal, type:
terminal-notifier -message "Starting sync"
Create a sh script to test the rsync + notification. Save it anywhere you like, with the name you like. In this example, I'll call it ~/Scripts/sync.sh I used the ".sh extension, but I don't know if its needed.
#!/bin/bash
terminal-notifier -message "Starting sync"
rsync -azP ~/Sites/folder/ user#host.com:site_folder/
terminal-notifier -message "Sync has finished"
3.1. Remember to give execution permission to this sh script. In Terminal, type:
sudo chmod 777 ~/Scripts/sync.sh
3.2. Run the script and verify if the messages are displayed correctly and the rsync actually sync your local folder with the remote folder.
Finally, I downloaded and installed Watchdog from the Github page: http://cl.ly/MJfb
4.1. First, I installed the libyaml dependency using Brew (there are lot's of help how to install Brew - like an "aptitude" for OS X). In Terminal, type:
brew install libyaml
4.2. Then, I used the "easy_install command". Go the folder of Watchdog, and type in Terminal:
easy_install watchdog
Now, everything is installed! Go the folder you want to be synced, change this code to your needs, and type in Terminal:
watchmedo shell-command
--patterns="*.php;*.txt;*.js;*.css" \
--recursive \
--command='~/Scripts/Sync.sh' \
.
It has to be EXACTLY this way, with the slashes and line breaks, so you'll have to copy these lines to a text editor, change the script, paste in terminal and press return.
I tried without the line breaks, and it doesn't work!
In my Mac, I always get an error, but it doesn't seem to affect anything:
/Library/Python/2.7/site-packages/argh-0.22.0-py2.7.egg/argh/completion.py:84: UserWarning: Bash completion not available. Install argcomplete.
Now, made some changes in a file inside the folder, and watch the magic!
I believe transmit does this.

Resources