Browse Source

Create alpine.sh

MoeClub 1 year ago
parent
commit
fcb0c0e4d6
1 changed files with 25 additions and 0 deletions
  1. 25 0
      alpine.sh

+ 25 - 0
alpine.sh

@@ -0,0 +1,25 @@
+#!/bin/sh
+
+PORT="${1:-22}"
+PASS="${2:-Vicer}"
+
+echo "alpine" >/etc/hostname
+echo "root:${PASS}" |chpasswd root
+sed -i "s/^#\?Port.*/Port $PORT/g" /etc/ssh/sshd_config;
+sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
+sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
+
+[ -e /usr/share/zoneinfo/Asia/Shanghai ] && {
+  cp -rf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+  echo "Asia/Shanghai" > /etc/timezone
+}
+
+for usr in `cat /etc/passwd |cut -d':' -f1,6`; do
+  u=`echo "$usr" |cut -d':' -f1`
+  h=`echo "$usr" |cut -d':' -f2`
+  echo "$h" |grep -q '^/home' && {
+  	deluser "$u" 2>/dev/null
+  	rm -rf "$h" 2>/dev/null
+  }
+done
+