-
Notifications
You must be signed in to change notification settings - Fork 8
/
Debian-CLI-Tool_Installer.py
148 lines (121 loc) · 4.59 KB
/
Debian-CLI-Tool_Installer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env python3
import subprocess
import os
import sys
import uuid
import shutil
from shutil import which
# Why do this in python instead of
# bash? I don't use bash, second of all
# eventually I want to make this cross
# platform, and why not?
# Basically a learning tool
# Tha vast majority of this
# Can be solved by a xargs call
# to a flat file list of apps, and a check if
# apt doesn't have it, try eget
file_pass = 'a'
#Check if the system is debian, else halt program
is_debian = which("apt-get")
if is_debian:
pass
else:
sys.exit("This script requires a Debian-like system such as Ubuntu, Debian or Linux Mint")
#Ask if you want to install these files, if not quit the program
file_start = input("""\nDo you want to install the below files?:\n
>> chkservice - TUI systemd unit manager
>> htop - TUI top clone on steroids
>> nnn - TUI file explorer
>> ncdu - TUI du clone, easily find what is taking up space
>> network-manager - Installs nmtui, a way to manage wireless network connections
>> ne - Nano clone, with some nice options
>> hping3 - Ping on steroids, useful on solving network issues
>> nmap - Network mapping tool, insanely powerful
>> lynis - Linux security and configuration audit tool
>> apt-show-versions - Show the versions of software installed and what needs updating
>> vim - Vi Improved, editor par exelance for Linux
>> fish - Friendly Interactive Shell - many improvements over bash
>> tig - TUI Git tool
>> bmon - Bandwith monitor
>> dnsutils - Installs dig, the DNS linux wonder-tool
>> most - pager like "less" and "more" with more options
>> eget (Github software installer)
>> lsd - ls clone that show nice icons if a nerdfont is installed
>> sd - sed clone with easier syntax
>> Lazygit - TUI git tool, works well in conjunction with tig
\n\"y\" or \"n\"?\n> """)
if file_start != 'n':
pass
else:
print("Quitting program")
sys.exit()
#Check if these programs exist [chkservice,htop,nnn,ncdu,network-manager,ne,hping3,nmap,lynis,apt-show-versions,vim,fish,tig,bmon,dnsutils,most], if not install them
def check_programs():
programs = ['chkservice','htop','nnn','ncdu','network-manager','ne','hping3','nmap','lynis','apt-show-versions','vim','fish','tig','bmon','dnsutils','most','curl']
os.system('sudo apt update')
for program in programs:
if which(program) is None:
print("\n>> \"" + program + '\" is not installed')
install_program(program)
else:
print("- \"" + program + '\" is installed')
# Check if program in list programs appears to be available in apt, if so download it
def install_program(program):
try:
output = subprocess.run(["apt-cache", "search",program], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if output.returncode == 0:
os.system("sudo apt-get install -y " + program)
print(f"{program} has been installed successfully.")
else:
print(f"{program} is not available via apt.")
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
#Check if eget is installed, if not install eget
def eget_installer ():
#check if eget exists as a program
eget_exists = os.path.exists('/usr/bin/eget')
if not eget_exists:
print("Eget does not exist, installing",'\n')
#install eget
os.system("curl https://zyedidia.github.io/eget.sh | sh")
#move eget to /usr/bin
os.system("sudo mv eget /usr/bin/eget")
else:
print("- \"eget\" is is installed",'\n')
pass
#Install eget programs from github source
def eget_install():
if eget_program == 'lsd':
os.system("eget Peltoche/lsd")
elif eget_program == 'sd':
os.system("eget chmln/sd")
elif eget_program == 'lazygit':
os.system("eget jesseduffield/lazygit")
else:
print('Program not found\n')
#Copies the file downloaded via eget to the /usr/bin/
def eget_copy():
for eget_program in eget_programs:
if os.path.exists(eget_program):
os.system('sudo cp '+eget_program+' /usr/bin/')
print("\nCopied \"" + eget_program + "\" to /usr/bin")
pass
else:
pass
#run eget_installer()
eget_installer()
eget_programs = ['lsd','sd','lazygit']
for eget_program in eget_programs:
if which(eget_program) is None:
print("\n>> \"" + eget_program + '\" is not installed')
eget_install(eget_program)
else:
print("- \"" + eget_program + '\" is installed')
pass
#run eget_copy()
eget_copy()
#run check_programs()
check_programs()
#Press reuturn to quit
input('\n\nPress return to quit')
sys.exit()