Skip to content

Commit 87d862f

Browse files
committed
Added -S to sudo
1 parent ed7c1b6 commit 87d862f

18 files changed

Lines changed: 72 additions & 67 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ If this repo was useful to you, feel free to buy us some coffee! :)
179179

180180
### VERSIONS
181181

182+
#### v0.28
183+
184+
- Added -S (--stdin) to all sudo commands so that users can directly run app inside a container from the host(ie. `incus exec container -- app -r all`)
185+
186+
182187
#### v0.27
183188

184189
- Fixed restore repositories

arch/pacman.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"syscall"
1212
)
1313

14-
var sudo = [3]string{"/usr/bin/sudo", "/bin/sh", "-c"}
14+
var sudo = [4]string{"/usr/bin/sudo", "-S", "/bin/sh", "-c"}
1515
var cmd = "/usr/bin/pacman"
1616

1717
func Install(pkg string) {
@@ -26,7 +26,7 @@ func Install(pkg string) {
2626
utils.PrintErrorMsgExit(pkg+" is already installed...", "")
2727
}
2828

29-
install := exec.Command(sudo[0], sudo[1], sudo[2], cmd+" -S "+pkg)
29+
install := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], cmd+" -S "+pkg)
3030
utils.RunCmd(install, "Installation Error:")
3131

3232
fmt.Println("\n Recording " + pkg + " to app history...\n")
@@ -49,7 +49,7 @@ func Remove(pkg string) {
4949
utils.PrintErrorMsgExit(pkg+" was not installed by app...", "")
5050
}
5151

52-
remove := exec.Command(sudo[0], sudo[1], sudo[2], cmd+" -R "+pkg)
52+
remove := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], cmd+" -R "+pkg)
5353
utils.RunCmd(remove, "Remove Error:")
5454

5555
fmt.Println("\n Removing " + pkg + " from app history...\n")
@@ -78,7 +78,7 @@ func AutoRemove() {
7878
fmt.Println("No packages need to be automatically removed...\n")
7979
os.Exit(1)
8080
}
81-
aRemove := exec.Command(sudo[0], sudo[1], sudo[2], "/usr/bin/pacman -Rns "+rmList)
81+
aRemove := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], "/usr/bin/pacman -Rns "+rmList)
8282
utils.RunCmd(aRemove, "Auto Remove Error:")
8383

8484
}
@@ -104,7 +104,7 @@ func Update() {
104104
action := " -Syy"
105105
command := cmd + action
106106

107-
update := exec.Command(sudo[0], sudo[1], sudo[2], command)
107+
update := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command)
108108
utils.RunCmd(update, "Update Error:")
109109

110110
}
@@ -116,7 +116,7 @@ func Upgrade() {
116116
upgrade := exec.Command("/usr/bin/garuda-update")
117117
utils.RunCmd(upgrade, "Upgrade Error:")
118118
default:
119-
upgrade := exec.Command(sudo[0], sudo[1], sudo[2], cmd+" -Syyu")
119+
upgrade := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], cmd+" -Syyu")
120120
utils.RunCmd(upgrade, "Upgrade Error:")
121121
}
122122

@@ -147,7 +147,7 @@ func InstallAll() {
147147
}
148148

149149
command := cmd + " -S "
150-
install := exec.Command(sudo[0], sudo[1], sudo[2], command+pkgs)
150+
install := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command+pkgs)
151151
utils.RunCmd(install, "Installation Error:")
152152

153153
}

arch/paru_repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func ParuAddRepo(s, g string, restore bool) {
4242
utils.PrintErrorMsgExit("File Syntax Error:", "Did you add #!/bin/bash to the top of the script?")
4343
}
4444
os.Chmod(sFull, 0755)
45-
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sFull)
45+
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], sFull)
4646
utils.RunCmd(runScript, "Script Error:")
4747
utils.CreateDirIfNotExist(env.DBDir + "/packages/repo/local/paru")
4848
utils.Copy(sFull, env.DBDir+"/packages/repo/local/paru/"+s)
@@ -85,7 +85,7 @@ func ParuRemoveRepo(s string) {
8585
utils.PrintErrorMsgExit("File Syntax Error:", "Did you add #!/bin/bash to the top of the script?")
8686
}
8787
os.Chmod(sFull, 0755)
88-
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sFull)
88+
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], sFull)
8989
utils.RunCmd(runScript, "Script Error:")
9090

9191
// Record removed repo

arch/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func AddRepo(s, g string, restore bool) {
4242
utils.PrintErrorMsgExit("File Syntax Error:", "Did you add #!/bin/bash to the top of the script?")
4343
}
4444
os.Chmod(sFull, 0755)
45-
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sFull)
45+
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], sFull)
4646
utils.RunCmd(runScript, "Script Error:")
4747
utils.CreateDirIfNotExist(env.DBDir + "/packages/repo/local/pacman")
4848
utils.Copy(sFull, env.DBDir+"/packages/repo/local/pacman/"+s)
@@ -85,7 +85,7 @@ func RemoveRepo(s string) {
8585
utils.PrintErrorMsgExit("File Syntax Error:", "Did you add #!/bin/bash to the top of the script?")
8686
}
8787
os.Chmod(sFull, 0755)
88-
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sFull)
88+
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], sFull)
8989
utils.RunCmd(runScript, "Script Error:")
9090

9191
// Record removed repo

arch/yay_repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func YayAddRepo(s, g string, restore bool) {
4242
utils.PrintErrorMsgExit("File Syntax Error:", "Did you add #!/bin/bash to the top of the script?")
4343
}
4444
os.Chmod(sFull, 0755)
45-
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sFull)
45+
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], sFull)
4646
utils.RunCmd(runScript, "Script Error:")
4747
utils.CreateDirIfNotExist(env.DBDir + "/packages/repo/local/yay")
4848
utils.Copy(sFull, env.DBDir+"/packages/repo/local/yay/"+s)
@@ -85,7 +85,7 @@ func YayRemoveRepo(s string) {
8585
utils.PrintErrorMsgExit("File Syntax Error:", "Did you add #!/bin/bash to the top of the script?")
8686
}
8787
os.Chmod(sFull, 0755)
88-
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sFull)
88+
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], sFull)
8989
utils.RunCmd(runScript, "Script Error:")
9090

9191
// Record removed repo

debian/apt.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"syscall"
1212
)
1313

14-
var sudo = [3]string{"/usr/bin/sudo", "/bin/sh", "-c"}
14+
var sudo = [4]string{"/usr/bin/sudo", "-S", "/bin/sh", "-c"}
1515
var cmd = "/usr/bin/apt"
1616

1717
func Install(pkg string) {
@@ -39,7 +39,7 @@ func Install(pkg string) {
3939
command = cmd + " -y" + action
4040
}
4141

42-
install := exec.Command(sudo[0], sudo[1], sudo[2], command+pkg)
42+
install := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command+pkg)
4343
utils.RunCmd(install, "Installation Error:")
4444

4545
fmt.Println("\n Recording " + pkg + " to app history...\n")
@@ -68,7 +68,7 @@ func Remove(pkg string) {
6868
command = cmd + " -y" + action
6969
}
7070

71-
remove := exec.Command(sudo[0], sudo[1], sudo[2], command+pkg)
71+
remove := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command+pkg)
7272
utils.RunCmd(remove, "Remove Error:")
7373

7474
fmt.Println("\n Removing " + pkg + " from app history...\n")
@@ -97,7 +97,7 @@ func Purge(pkg string) {
9797
command = cmd + " -y" + action
9898
}
9999

100-
purge := exec.Command(sudo[0], sudo[1], sudo[2], command+pkg)
100+
purge := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command+pkg)
101101
utils.RunCmd(purge, "Purge Error:")
102102

103103
fmt.Println("\n Removing " + pkg + " from app history...\n")
@@ -116,7 +116,7 @@ func AutoRemove() {
116116
command = cmd + " -y" + action
117117
}
118118

119-
err := syscall.Exec(sudo[0], []string{sudo[0], sudo[1], sudo[2], command}, os.Environ())
119+
err := syscall.Exec(sudo[0], []string{sudo[0], sudo[1], sudo[2], sudo[3], command}, os.Environ())
120120
if err != nil {
121121
utils.PrintErrorExit("Auto Remove Error:", err)
122122
}
@@ -149,7 +149,7 @@ func Update() {
149149
command = cmd + " -y" + action
150150
}
151151

152-
update := exec.Command(sudo[0], sudo[1], sudo[2], command)
152+
update := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command)
153153
utils.RunCmd(update, "Update Error:")
154154

155155
}
@@ -162,7 +162,7 @@ func Upgrade() {
162162
command = cmd + " -y" + action
163163
}
164164

165-
upgrade := exec.Command(sudo[0], sudo[1], sudo[2], command)
165+
upgrade := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command)
166166
utils.RunCmd(upgrade, "Upgrade Error:")
167167

168168
}
@@ -175,7 +175,7 @@ func DistUpgrade() {
175175
command = cmd + " -y" + action
176176
}
177177

178-
distUpgrade := exec.Command(sudo[0], sudo[1], sudo[2], command)
178+
distUpgrade := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command)
179179
utils.RunCmd(distUpgrade, "Dist Upgrade Error:")
180180

181181
}
@@ -203,7 +203,7 @@ func InstallAll() {
203203
command = cmd + " -y" + action
204204
}
205205

206-
install := exec.Command(sudo[0], sudo[1], sudo[2], command+pkgs)
206+
install := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], command+pkgs)
207207
utils.RunCmd(install, "Installation Error:")
208208

209209
}

debian/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func AddRepo(s, g string, restore bool) {
3838

3939
switch sType {
4040
case "ppa":
41-
cmd := exec.Command(sudo[0], sudo[1], sudo[2], "add-apt-repository "+s)
41+
cmd := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], "add-apt-repository "+s)
4242
utils.RunCmd(cmd, "Add Repo Error:")
4343
name = s
4444
case "sh":
@@ -56,7 +56,7 @@ func AddRepo(s, g string, restore bool) {
5656
utils.PrintErrorMsgExit("File Syntax Error:", "Did you add #!/bin/bash to the top of the script?")
5757
}
5858
os.Chmod(sFull, 0755)
59-
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sFull)
59+
runScript := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], sFull)
6060
utils.RunCmd(runScript, "Script Error:")
6161
utils.CreateDirIfNotExist(env.DBDir + "/packages/repo/local/apt")
6262
utils.Copy(sFull, env.DBDir+"/packages/repo/local/apt/"+s)
@@ -94,13 +94,13 @@ func RemoveRepo(s string) {
9494

9595
switch sType {
9696
case "ppa":
97-
cmd := exec.Command(sudo[0], sudo[1], sudo[2], "add-apt-repository --remove "+s)
97+
cmd := exec.Command(sudo[0], sudo[1], sudo[2], sudo[3], "add-apt-repository --remove "+s)
9898
utils.RunCmd(cmd, "Remove Repo Error:")
9999
default:
100100
sources := strings.Split(s, " ")
101101
for i := 0; i < len(sources); i++ {
102102
fmt.Println("Removing /etc/apt/sources.list.d/" + sources[i] + ".list with sudo:")
103-
rmRepo := exec.Command("/usr/bin/sudo", "/bin/bash", "-c", "rm /etc/apt/sources.list.d/"+sources[i]+".list")
103+
rmRepo := exec.Command("/usr/bin/sudo", "-S", "/bin/bash", "-c", "rm /etc/apt/sources.list.d/"+sources[i]+".list")
104104
utils.RunCmd(rmRepo, "Repo Remove Error:")
105105
}
106106
}

dist/getapp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# app installer #
55
#################
66

7-
VER="v0.27"
7+
VER="v0.28"
88
CYAN='\033[0;36m'
99
GREEN='\033[1;32m'
1010
NC='\033[0m'

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<a target="_blank" href="https://github.com/hkdb/app"><img class="logo" src="github.png"></a>
8484
</div>
8585
<div>
86-
<p class="version">Latest: v0.27 (ALPHA)</p>
86+
<p class="version">Latest: v0.28 (ALPHA)</p>
8787
</div>
8888
<script>
8989
// Get the <pre> element

dist/updateapp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# app updater #
55
###############
66

7-
VER="v0.27"
7+
VER="v0.28"
88
CYAN='\033[0;36m'
99
GREEN='\033[1;32m'
1010
NC='\033[0m'

0 commit comments

Comments
 (0)