Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
Fixes #1118
Browse files Browse the repository at this point in the history
  • Loading branch information
karasu committed Jan 4, 2019
1 parent 39998a4 commit 8274648
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

""" Set some Cnchi global constants """

CNCHI_VERSION = "0.16.46"
CNCHI_VERSION = "0.16.47"
""" Cnchi version """

CNCHI_WEBSITE = "http://www.antergos.com"
Expand Down
62 changes: 43 additions & 19 deletions src/installation/post_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ def setup(self):
services = []
masked = []

if self.settings.get("feature_aur"):
if self.settings.get('feature_aur'):
self.enable_aur_in_pamac()

if self.settings.get("feature_bluetooth"):
if self.settings.get('feature_bluetooth'):
services.append('bluetooth')

if self.settings.get("feature_cups"):
if self.settings.get('feature_cups'):
services.append('org.cups.cupsd')
services.append('avahi-daemon')
self.enable_mdns()

# openssh comes with two kinds of systemd service files:
# sshd.service, which will keep the SSH daemon permanently active and
Expand All @@ -62,47 +63,47 @@ def setup(self):
# daemon per connection. Using it implies that systemd listens on the SSH
# socket and will only start the daemon process for an incoming connection.
# It is the recommended way to run sshd in almost all cases.
if self.settings.get("feature_sshd"):
if self.settings.get('feature_sshd'):
services.append('sshd.socket')

if self.settings.get("feature_firewall"):
if self.settings.get('feature_firewall'):
logging.debug("Configuring firewall...")
# Set firewall rules
firewall.run(["default", "deny"])
firewall.run(['default', 'deny'])
toallow = misc.get_network()
if toallow:
firewall.run(["allow", "from", toallow])
firewall.run(["allow", "Transmission"])
firewall.run(["allow", "SSH"])
firewall.run(["enable"])
firewall.run(['allow', 'from', toallow])
firewall.run(['allow', 'Transmission'])
firewall.run(['allow', 'SSH'])
firewall.run(['enable'])
services.append('ufw')

if self.settings.get('feature_lts'):
self.set_kernel_lts()

if (self.settings.get("feature_lamp") and
not self.settings.get("feature_lemp")):
if (self.settings.get('feature_lamp') and
not self.settings.get('feature_lemp')):
try:
from installation import lamp
logging.debug("Configuring LAMP...")
lamp.setup()
services.extend(["httpd", "mysqld"])
services.extend(['httpd', 'mysqld'])
except ImportError as import_error:
logging.warning(
"Unable to import LAMP module: %s",
str(import_error))
elif self.settings.get("feature_lemp"):
elif self.settings.get('feature_lemp'):
try:
from installation import lemp
logging.debug("Configuring LEMP...")
lemp.setup()
services.extend(["nginx", "mysqld", "php-fpm"])
services.extend(['nginx', 'mysqld', 'php-fpm'])
except ImportError as import_error:
logging.warning(
"Unable to import LEMP module: %s",
str(import_error))

if self.settings.get("feature_energy"):
if self.settings.get('feature_energy'):
# tlp
services.extend(['tlp.service', 'tlp-sleep.service'])
masked.extend(['systemd-rfkill.service', 'systemd-rfkill.socket'])
Expand All @@ -112,9 +113,32 @@ def setup(self):
srv.mask_services(masked)
srv.enable_services(services)

def enable_mdns(self):
""" Modify nsswitch.conf to use mdns for local wifi printers """
path = '/etc/nsswitch.conf'
lines = self.read_file_from_install(path)
if lines:
path = os.path.join(self.dest_dir, path[1:])
if os.path.exists(path):
search_line = "hosts: files mymachines myhostname resolve [!UNAVAIL = return] dns"
try:
with open(path, 'w') as nsswitch:
for line in lines:
if search_line in line:
line = "hosts: files mymachines myhostname "
line += "mdns_minimal [NOTFOUND = return] "
line += "resolve [!UNAVAIL = return] dns"
nsswitch.write(line + '\n')
except OSError as err:
logging.error("Couldn't modify %s file: %s", path, err)


def read_file_from_install(self, path):
""" Read file from new installation /install """
lines = []
# remove leading / to join it to dest_dir path
if path[0] == '/':
path = path[1:]
path = os.path.join(self.dest_dir, path)
try:
with open(path) as grub_cfg:
Expand All @@ -138,7 +162,7 @@ def set_kernel_lts(self):
def set_kernel_lts_grub(self):
""" Sets LTS kernel as default in Grub """
# Get menu options
path = 'boot/grub.cfg'
path = '/boot/grub.cfg'
lines = self.read_file_from_install(path)

menu_entries = []
Expand All @@ -156,9 +180,9 @@ def set_kernel_lts_grub(self):
break

if new_default:
path = 'etc/default/grub'
path = '/etc/default/grub'
lines = self.read_file_from_install(path)
path = os.path.join(self.dest_dir, path)
path = os.path.join(self.dest_dir, path[1:])
with open(path, 'wt') as grub_file:
for line in lines:
if "GRUB_DEFAULT" in line:
Expand Down
4 changes: 4 additions & 0 deletions src/installation/post_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ def setup_user(self):
chroot_call(['groupadd', 'autologin'])
default_groups += ',autologin'

if self.settings.get('feature_cups'):
# Add user to group sys so wifi printers work
default_groups += ',sys'

cmd = [
'useradd', '--create-home',
'--shell', '/bin/bash',
Expand Down
2 changes: 1 addition & 1 deletion update.info
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"version":"0.16.46","files":[
{"version":"0.16.47","files":[
]}

1 comment on commit 8274648

@killajoe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

Please sign in to comment.