<commit_before>#
# Cookbook Name:: basics
# Recipe:: sshusers
#
# Copyright 2012, Cogini
#

sftp = node[:ssh][:sftp]
sftp_users = sftp[:users]
sftp_upload_dir = sftp[:upload_dir]


service node[:ssh][:service] do
    action [:enable, :start]
end


sysadmins = node[:admin_users] | node[:sudoers]
ssh_users = node[:ssh][:users] | sysadmins.collect { |u| u[:username] }

ssh_users.each do |u|
    user u do
        shell '/bin/bash'
        supports :manage_home=>true
    end
end

group node[:ssh][:group] do
    members ssh_users
    action :create
end


# SFTP users and group

sftp_users.each do |sftp_user|
    user sftp_user do
        home "/#{sftp_upload_dir}"
        shell sftp[:shell]
        action :create
    end
    directory "#{sftp[:dir]}/#{sftp_user}/#{sftp_upload_dir}" do
        action :create
        recursive true
        owner sftp_user
    end
end

group sftp[:group] do
    members sftp_users
    action :create
end


template '/etc/ssh/sshd_config' do
    source 'sshd_config.erb'
    mode '0644'
    notifies :restart, "service[#{node[:ssh][:service]}]"
end<commit_msg>give sftp users proper homes<commit_after>#
# Cookbook Name:: basics
# Recipe:: sshusers
#
# Copyright 2012, Cogini
#

sftp = node[:ssh][:sftp]
sftp_users = sftp[:users]
sftp_upload_dir = sftp[:upload_dir]


service node[:ssh][:service] do
    action [:enable, :start]
end


sysadmins = node[:admin_users] | node[:sudoers]
ssh_users = node[:ssh][:users] | sysadmins.collect { |u| u[:username] }

ssh_users.each do |u|
    user u do
        shell '/bin/bash'
        supports :manage_home=>true
    end
end

group node[:ssh][:group] do
    members ssh_users
    action :create
end


# SFTP users and group

sftp_users.each do |sftp_user|
    user sftp_user do
        home "/srv/sftp/#{sftp_user}"
        shell sftp[:shell]
        action :create
    end
    directory "#{sftp[:dir]}/#{sftp_user}/#{sftp_upload_dir}" do
        action :create
        recursive true
        owner sftp_user
    end
end

group sftp[:group] do
    members sftp_users
    action :create
end


template '/etc/ssh/sshd_config' do
    source 'sshd_config.erb'
    mode '0644'
    notifies :restart, "service[#{node[:ssh][:service]}]"
end
{'fraction_non_alphanumeric': 0.12850678733031673, 'fraction_numerical': 0.007239819004524887, 'mean_word_length': 3.260115606936416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6923100', 'n_tokens_mistral': 883, 'n_tokens_neox': 798, 'n_words': 197}