From 638d21a0a1c0b592e5c103b7908528b0c38d43d7 Mon Sep 17 00:00:00 2001 From: filesite Date: Sat, 5 Nov 2022 20:33:37 +0800 Subject: [PATCH] add script for samba install and config --- Dockerfile | 6 ++++++ Dockerfile_samba | 27 +++++++++++++++++++++++++-- bin/install.sh | 37 +++++++++++++++++++++++++++++++++++++ bin/smbpwd.sh | 18 ++++++++++++++++++ bin/upgrade.sh | 6 ++++++ conf/smb.conf | 7 +++++++ docker-entrypoint.sh | 7 ++++++- 7 files changed, 105 insertions(+), 3 deletions(-) create mode 100755 bin/smbpwd.sh create mode 100644 conf/smb.conf diff --git a/Dockerfile b/Dockerfile index 88bc291..8a66295 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,12 @@ RUN apk add \ && mv machete/ /var/www/ \ && cd /var/www/ && rm -rf downloads/ \ && mkdir machete/www/navs/ && mkdir machete/www/girls/ && mkdir machete/www/videos/ \ + && cd machete/ \ + && chown apache:apache runtime/ \ + && chown -R apache:apache www/content/ \ + && chown apache:apache www/navs/ \ + && chown apache:apache www/girls/ \ + && chown apache:apache www/videos/ \ && rm -f /etc/nginx/http.d/default.conf \ && cp /var/www/machete/conf/nginx_machete.conf /etc/nginx/http.d/machete.conf diff --git a/Dockerfile_samba b/Dockerfile_samba index 281dc18..58bac7f 100644 --- a/Dockerfile_samba +++ b/Dockerfile_samba @@ -5,7 +5,7 @@ RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.n && yum -y install yum-utils \ && yum-config-manager --disable 'remi-php*' \ && yum-config-manager --enable remi-safe \ - && yum -y install php82-php-fpm php82-php-gd php82-php-mbstring nginx wget rsync \ + && yum -y install php82-php-fpm php82-php-gd php82-php-mbstring nginx wget rsync samba \ && ln -s /opt/remi/php82/root/usr/sbin/php-fpm /usr/sbin/php-fpm \ && cd /etc/opt/remi/php82/ \ && sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 10M/g' php.ini \ @@ -15,10 +15,33 @@ RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.n && mv machete/ /var/www/ \ && cd /var/www/ && rm -rf downloads/ \ && mkdir machete/www/navs/ && mkdir machete/www/girls/ && mkdir machete/www/videos/ \ + && cd machete/ \ + && chown apache:apache runtime/ \ + && chown -R apache:apache www/content/ \ + && chown apache:apache www/navs/ \ + && chown apache:apache www/girls/ \ + && chown apache:apache www/videos/ \ && rm -f /etc/nginx/nginx.conf \ && cp /var/www/machete/conf/nginx.conf /etc/nginx/nginx.conf \ && cp /var/www/machete/conf/nginx_machete.conf /etc/nginx/conf.d/machete.conf \ - && ln -s /var/www/machete/bin/upgrade.sh /usr/bin/upgrade_machete + && ln -s /var/www/machete/bin/upgrade.sh /usr/bin/upgrade_machete \ + && mkdir -p /var/www/sambashare/filesite/ \ + && cd /var/www/sambashare/filesite/ \ + && mv /var/www/machete/www/content/ ./ \ + && mv /var/www/machete/www/navs/ ./ \ + && mv /var/www/machete/www/girls/ ./ \ + && mv /var/www/machete/www/videos/ ./ \ + && ln -s /var/www/sambashare/filesite/content/ /var/www/machete/www/content \ + && ln -s /var/www/sambashare/filesite/navs/ /var/www/machete/www/navs \ + && ln -s /var/www/sambashare/filesite/girls/ /var/www/machete/www/girls \ + && ln -s /var/www/sambashare/filesite/videos/ /var/www/machete/www/videos \ + && chgrp apache /var/www/sambashare/ \ + && useradd -M -d /var/www/sambashare/filesite -s /usr/sbin/nologin -G apache filesite \ + && chown -R filesite:apache /var/www/sambashare/filesite \ + && chmod -R 770 /var/www/sambashare/filesite \ + && rm -f /etc/samba/smb.conf && cp /var/www/machete/conf/smb.conf /etc/samba/ \ + && /var/www/machete/bin/smbpwd.sh filesite 88888888 \ + && ln -s /var/www/machete/bin/smbpwd.sh /usr/bin/smbpwd EXPOSE 80/tcp ENTRYPOINT ["/var/www/machete/docker-entrypoint.sh"] diff --git a/bin/install.sh b/bin/install.sh index 5774a0e..0a502e3 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -9,6 +9,7 @@ yum-config-manager --enable remi-safe yum -y install php82-php-fpm php82-php-gd php82-php-mbstring yum -y install nginx yum -y install wget +yum -y install samba ln -s /opt/remi/php82/root/usr/sbin/php-fpm /usr/sbin/php-fpm php-fpm -v @@ -31,6 +32,42 @@ sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 10M/g' php.ini #/usr/sbin/nginx +## samba user and directory config +#mkdir -p /var/www/sambashare/filesite/ + +#cd /var/www/sambashare/filesite/ +#mv /var/www/machete/www/content/ ./ +#mv /var/www/machete/www/navs/ ./ +#mv /var/www/machete/www/girls/ ./ +#mv /var/www/machete/www/videos/ ./ +#ln -s /var/www/sambashare/filesite/content/ /var/www/machete/www/content +#ln -s /var/www/sambashare/filesite/navs/ /var/www/machete/www/navs +#ln -s /var/www/sambashare/filesite/girls/ /var/www/machete/www/girls +#ln -s /var/www/sambashare/filesite/videos/ /var/www/machete/www/videos + +#chgrp apache /var/www/sambashare/ +#useradd -M -d /var/www/sambashare/filesite -s /usr/sbin/nologin -G apache filesite +#chown -R filesite:apache /var/www/sambashare/filesite +#chmod -R 770 /var/www/sambashare/filesite +#smbpasswd -a filesite +#smbpasswd -e filesite + + +## start samba +#/usr/sbin/smbd -D + +## open port for http and https +#firewall-cmd –-permanent –-add-service=http +#firewall-cmd –-permanent –-add-service=https + + +## open port for samba +#firewall-cmd –-permanent –-add-service=samba +#firewall-cmd –-reload + + + + ## php82-fpm's path ##/etc/logrotate.d/php82-php-fpm ##/etc/opt/remi/php82/php-fpm.conf diff --git a/bin/smbpwd.sh b/bin/smbpwd.sh new file mode 100755 index 0000000..8edb0d7 --- /dev/null +++ b/bin/smbpwd.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +username=$1 +password=$2 + +if [ -z $username ]; then + user='filesite' +fi + +if [ -z $password ]; then + user='88888888' +fi + +#sleep 3 +smbpasswd -a $username<